summaryrefslogtreecommitdiff
path: root/src/libostree/ostree-repo-libarchive.c
diff options
context:
space:
mode:
authorKrzesimir Nowak <krzesimir@kinvolk.io>2016-05-11 11:04:04 +0200
committerColin Walters (automation) <walters+githubbot@verbum.org>2016-05-12 11:17:09 +0000
commit862e6ecdcc58f025696b1394adfc0fcf7322df23 (patch)
tree6ff27b7b6c6fddb237716f8e1790d56287d7ee64 /src/libostree/ostree-repo-libarchive.c
parentaa946cc13636bc45f45f8850e47c456a6019d363 (diff)
downloadostree-862e6ecdcc58f025696b1394adfc0fcf7322df23.tar.gz
libostree: Variant-related leak plugs and fixes
This tries to avoid leaking GVariantBuilders and GVariants in some situations. The leaks were usually happening when some error occurred or because of unclear variant ownership situation. The former is mostly about making sure that g_variant_builder_clear is called on builders that didn't finish their variant building process. The latter is surely more work - sometimes the result of g_variant_builder_end() should not be passed directly to a function, but rather stored in a g_autoptr(GVariant), sunk and then passed to a function. IMO, with an advent of g_autoptr, GVariants should be always sunk instead of relying on some receiver function sinking it. This would make an easy-to-follow policy of always sinking your variants. Functions could then assume that the passed variant is already sunk. These leaks are still happenning in commands, but they are less harmful, since that code will not be used by some daemon as a library routine. Closes: #291 Approved by: cgwalters
Diffstat (limited to 'src/libostree/ostree-repo-libarchive.c')
-rw-r--r--src/libostree/ostree-repo-libarchive.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/libostree/ostree-repo-libarchive.c b/src/libostree/ostree-repo-libarchive.c
index 57da41d4..0d62124d 100644
--- a/src/libostree/ostree-repo-libarchive.c
+++ b/src/libostree/ostree-repo-libarchive.c
@@ -331,6 +331,7 @@ aic_ensure_parent_dir_with_file_info (OstreeRepoArchiveImportContext *ctx,
{
const char *name = glnx_basename (fullpath);
g_auto(GVariantBuilder) xattrs_builder;
+ g_autoptr(GVariant) xattrs = NULL;
/* is this the root directory itself? transform into empty string */
if (name[0] == '/' && name[1] == '\0')
@@ -343,8 +344,9 @@ aic_ensure_parent_dir_with_file_info (OstreeRepoArchiveImportContext *ctx,
DEFAULT_DIRMODE, cancellable, error))
return FALSE;
+ xattrs = g_variant_ref_sink (g_variant_builder_end (&xattrs_builder));
return mtree_ensure_dir_with_meta (ctx->repo, parent, name, file_info,
- g_variant_builder_end (&xattrs_builder),
+ xattrs,
FALSE /* error_if_exist */, out_dir,
cancellable, error);
}