From dd3cda401beed444ff2229f1c56e74b2b9fa922e Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Wed, 21 Dec 2016 05:59:08 -0600 Subject: [PATCH] repo: Fix object list keys ownership ostree_object_name_serialize returns a floating ref, so sink it before adding it to the hash table so it can properly be freed later when the hash table is destroyed. This is particularly a problem for pygobject, which sinks the refs on variants as it marshals them to native python types. If the ref isn't already sunk, then the ref count won't increase and a critical warning will be raised when both the hash table and pygobject try to unref it. Closes: #635 Approved by: cgwalters --- src/libostree/ostree-repo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c index 92de1ed5..35136c76 100644 --- a/src/libostree/ostree-repo.c +++ b/src/libostree/ostree-repo.c @@ -2460,7 +2460,7 @@ list_loose_objects_at (OstreeRepo *self, value = g_variant_new ("(b@as)", TRUE, g_variant_new_strv (NULL, 0)); /* transfer ownership */ - g_hash_table_replace (inout_objects, key, + g_hash_table_replace (inout_objects, g_variant_ref_sink (key), g_variant_ref_sink (value)); }