[gnome-software] snap: Fix leak using plugin cache



commit d1dd8db7a88ce774fa8986f6536c718181563ef2
Author: Robert Ancell <robert ancell canonical com>
Date:   Wed Aug 29 21:11:58 2018 +1200

    snap: Fix leak using plugin cache
    
    The plugin cache returns a reference, and the snap code was assuming it didn't.

 plugins/snap/gs-plugin-snap.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
---
diff --git a/plugins/snap/gs-plugin-snap.c b/plugins/snap/gs-plugin-snap.c
index 0a6d85bc..49162d03 100644
--- a/plugins/snap/gs-plugin-snap.c
+++ b/plugins/snap/gs-plugin-snap.c
@@ -268,7 +268,6 @@ snap_to_app (GsPlugin *plugin, SnapdSnap *snap)
        GStrv common_ids;
        g_autofree gchar *appstream_id = NULL;
        g_autofree gchar *unique_id = NULL;
-       GsApp *cached_app;
        g_autoptr(GsApp) app = NULL;
        SnapdConfinement confinement;
 
@@ -294,15 +293,13 @@ snap_to_app (GsPlugin *plugin, SnapdSnap *snap)
                break;
        }
 
-       cached_app = gs_plugin_cache_lookup (plugin, unique_id);
-       if (cached_app == NULL) {
+       app = gs_plugin_cache_lookup (plugin, unique_id);
+       if (app == NULL) {
                app = gs_app_new (NULL);
                gs_app_set_from_unique_id (app, unique_id);
                gs_app_set_metadata (app, "snap::name", snapd_snap_get_name (snap));
                gs_plugin_cache_add (plugin, unique_id, app);
        }
-       else
-               app = g_object_ref (cached_app);
 
        gs_app_set_management_plugin (app, "snap");
        if (gs_app_get_kind (app) != AS_APP_KIND_DESKTOP)


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