Skip to content

Commit

Permalink
repo: Fix dir_or_file_path memory leak
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
lukewarmtemp committed Jun 20, 2024
1 parent 20d5bc8 commit d528083
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/libostree/ostree-repo-static-delta-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit d528083

Please sign in to comment.