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



commit c5d5b13176ab971d2716ccc42c35341d1d5cc383
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 6f3c4de8..4c7948fd 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]