From bbfdbe791615ec1f520e5777615f3929c5ba700a Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 30 Oct 2020 17:04:29 +0000 Subject: [PATCH] upgrader: Fix potential use of NULL value Current gcc in Fedora rawhide correctly points out: ``` In function 'generate_initramfs_overlay', inlined from 'rpmostree_sysroot_upgrader_deploy' at src/daemon/rpmostree-sysroot-upgrader.c:1604:12: src/daemon/rpmostree-sysroot-upgrader.c:1166:65: error: argument 1 null where non-null expected [-Werror=nonnull] 1166 | g_steal_pointer (&path), (strlen (path))+1, g_free); | ~^~~~~~~~~~~~~~ ``` --- src/daemon/rpmostree-sysroot-upgrader.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/daemon/rpmostree-sysroot-upgrader.c b/src/daemon/rpmostree-sysroot-upgrader.c index 7b160e45..16b02c4c 100644 --- a/src/daemon/rpmostree-sysroot-upgrader.c +++ b/src/daemon/rpmostree-sysroot-upgrader.c @@ -1162,8 +1162,10 @@ generate_initramfs_overlay (GHashTable *initramfs_etc_files, guint path_hash = g_str_hash (path); if (path_hash == last_path_hash) continue; + /* we want the trailing NUL too as a separator */ + const size_t n = strlen (path) + 1; g_memory_input_stream_add_data (G_MEMORY_INPUT_STREAM (filelist_input), - g_steal_pointer (&path), (strlen (path))+1, g_free); + g_steal_pointer (&path), n, g_free); last_path_hash = path_hash; }