[gnome-software/wip/ubuntu-3-20: 57/57] snap: Fix leak of GsApp



commit f9bc39ceb57de1e95a9e21c43214ce6d5869fa27
Author: Robert Ancell <robert ancell canonical com>
Date:   Fri Sep 29 11:19:19 2017 -0400

    snap: Fix leak of GsApp

 src/plugins/gs-plugin-snap.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/src/plugins/gs-plugin-snap.c b/src/plugins/gs-plugin-snap.c
index bf7bc29..9e8c1b6 100644
--- a/src/plugins/gs-plugin-snap.c
+++ b/src/plugins/gs-plugin-snap.c
@@ -183,7 +183,8 @@ gs_plugin_url_to_app (GsPlugin *plugin,
                return TRUE;
 
        snap = json_array_get_object_element (snaps, 0);
-       gs_plugin_add_app (list, snap_to_app (plugin, snap));
+       app = snap_to_app (plugin, snap);
+       gs_plugin_add_app (list, app);
 
        return TRUE;
 }
@@ -313,8 +314,8 @@ gs_plugin_add_popular (GsPlugin *plugin,
 
        /* skip first snap - it is used as the featured app */
        for (i = 1; i < json_array_get_length (snaps); i++) {
-               JsonObject *snap = json_array_get_object_element (snaps, i);
-               gs_plugin_add_app (list, snap_to_app (plugin, snap));
+               g_autoptr(GsApp) app = snap_to_app (plugin, json_array_get_object_element (snaps, i));
+               gs_plugin_add_app (list, app);
        }
 
        return TRUE;
@@ -335,13 +336,15 @@ gs_plugin_add_installed (GsPlugin *plugin,
 
        for (i = 0; i < json_array_get_length (snaps); i++) {
                JsonObject *snap = json_array_get_object_element (snaps, i);
+               g_autoptr(GsApp) app = NULL;
                const gchar *status;
 
                status = json_object_get_string_member (snap, "status");
                if (g_strcmp0 (status, "active") != 0)
                        continue;
 
-               gs_plugin_add_app (list, snap_to_app (plugin, snap));
+               app = snap_to_app (plugin, snap);
+               gs_plugin_add_app (list, app);
        }
 
        return TRUE;
@@ -364,8 +367,8 @@ gs_plugin_add_search (GsPlugin *plugin,
                return FALSE;
 
        for (i = 0; i < json_array_get_length (snaps); i++) {
-               JsonObject *snap = json_array_get_object_element (snaps, i);
-               gs_plugin_add_app (list, snap_to_app (plugin, snap));
+               g_autoptr(GsApp) app = snap_to_app (plugin, json_array_get_object_element (snaps, i));
+               gs_plugin_add_app (list, app);
        }
 
        return TRUE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]