sysroot: Make coverity happy with dirname+strdup
authorColin Walters <walters@verbum.org>
Thu, 15 Aug 2024 15:28:45 +0000 (11:28 -0400)
committerColin Walters <walters@verbum.org>
Thu, 15 Aug 2024 15:29:22 +0000 (11:29 -0400)
Similar to d528083cae3492f9b9424f3c9830869af7b4cbd0 - I don't
believe we actually had a leak here because `dirname` always
returns the same start pointer, but this makes Coverity
happy.

Signed-off-by: Colin Walters <walters@verbum.org>
src/libostree/ostree-sysroot.c

index af9e07c1ab5acdff7d2f7b4ce6ac2392f4d80bd3..925c66a7e3e2f5fba210bed21fa49a2768089a8a 100644 (file)
@@ -2243,7 +2243,8 @@ ostree_sysroot_deployment_unlock (OstreeSysroot *self, OstreeDeployment *deploym
                         deployment, _OSTREE_SYSROOT_DEPLOYMENT_RUNSTATE_FLAG_DEVELOPMENT)
                   : _ostree_sysroot_get_runstate_path (
                         deployment, _OSTREE_SYSROOT_DEPLOYMENT_RUNSTATE_FLAG_TRANSIENT);
-        g_autofree char *devpath_parent = dirname (g_strdup (devpath));
+        g_autofree char *devpath_parent_owned = g_strdup (devpath);
+        const char *devpath_parent = dirname (devpath_parent_owned);
 
         if (!glnx_shutil_mkdir_p_at (AT_FDCWD, devpath_parent, 0755, cancellable, error))
           return FALSE;