From f80cce6b8d6a397a232c3a88bf1411f7045cc5e4 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Mon, 29 Jul 2019 18:00:53 +0100 Subject: [PATCH] installation: Fix a small leak of a FlatpakCollectionRef Signed-off-by: Philip Withnall Closes: #3031 Approved by: mwleeds --- common/flatpak-installation.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/common/flatpak-installation.c b/common/flatpak-installation.c index 7fe20f02..7b651a27 100644 --- a/common/flatpak-installation.c +++ b/common/flatpak-installation.c @@ -976,6 +976,16 @@ async_result_cb (GObject *obj, *result_out = g_object_ref (result); } +/* Useful as the #GDestroyNotify in NULL-terminated pointer arrays. */ +static void +_ostree_collection_ref_free0 (OstreeCollectionRef *ref) +{ + if (ref == NULL) + return; + + ostree_collection_ref_free (ref); +} + /** * flatpak_installation_list_installed_refs_for_update: * @self: a #FlatpakInstallation @@ -1077,7 +1087,7 @@ flatpak_installation_list_installed_refs_for_update (FlatpakInstallation *self, if (dir == NULL) return NULL; - collection_refs = g_ptr_array_new (); + collection_refs = g_ptr_array_new_with_free_func ((GDestroyNotify) _ostree_collection_ref_free0); refs_str = g_string_new (""); for (i = 0; i < installed->len; i++)