From: Luke Yang Date: Wed, 12 Jun 2024 19:55:37 +0000 (-0400) Subject: repo: Fix `dir_or_file_path` memory leak X-Git-Tag: archive/raspbian/2024.8-1+rpi1^2~7^2~1^2~5^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=d528083cae3492f9b9424f3c9830869af7b4cbd0;p=ostree.git repo: Fix `dir_or_file_path` memory leak Coverity points out that we have a memory leak from `g_strdup(dir_or_file_path)`. Make the duplication of the string a temporary variable that is freed using `g_autofree`. --- diff --git a/src/libostree/ostree-repo-static-delta-core.c b/src/libostree/ostree-repo-static-delta-core.c index dc57a2f0..1a1b3309 100644 --- a/src/libostree/ostree-repo-static-delta-core.c +++ b/src/libostree/ostree-repo-static-delta-core.c @@ -409,7 +409,8 @@ ostree_repo_static_delta_execute_offline_with_signature (OstreeRepo *self, GFile return glnx_throw_errno_prefix (error, "openat(O_DIRECTORY)"); else { - g_autofree char *dir = dirname (g_strdup (dir_or_file_path)); + g_autofree char *tmpbuf = g_strdup (dir_or_file_path); + const char *dir = dirname (tmpbuf); basename = g_path_get_basename (dir_or_file_path); if (!glnx_opendirat (AT_FDCWD, dir, TRUE, &dfd, error))