Skip to content

Commit

Permalink
ostree/dump: Fix a memory leak
Browse files Browse the repository at this point in the history
Re-using the `refs` variable for the main list of refs, plus the
iterated lists, meant that the main list was never freed (although all
the iterated ones were freed correctly).

Fix this by using two variables rather than reusing the one.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
  • Loading branch information
pwithnall committed Oct 1, 2020
1 parent a74b8fb commit 464d2a3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ostree/ot-dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,11 @@ ot_dump_summary_bytes (GBytes *summary_bytes,
collection_map = g_variant_lookup_value (exts, OSTREE_SUMMARY_COLLECTION_MAP, G_VARIANT_TYPE ("a{sa(s(taya{sv}))}"));
if (collection_map != NULL)
{
g_autoptr(GVariant) collection_refs = NULL;
g_variant_iter_init (&iter, collection_map);

while (g_variant_iter_loop (&iter, "{&s@a(s(taya{sv}))}", &collection_id, &refs))
dump_summary_refs (collection_id, refs);
while (g_variant_iter_loop (&iter, "{&s@a(s(taya{sv}))}", &collection_id, &collection_refs))
dump_summary_refs (collection_id, collection_refs);
}

/* Print out the additional metadata. */
Expand Down

0 comments on commit 464d2a3

Please sign in to comment.