[gnome-software/gnome-3-26] shell-extensions: Fix a potentially sizable memory leak



commit f2898d566635c60e1b99d2b2b7f582bfa6170d91
Author: Richard Hughes <richard hughsie com>
Date:   Thu Oct 19 17:18:28 2017 +0100

    shell-extensions: Fix a potentially sizable memory leak
    
    This only happens when the shell extension has an invalid icon, or the shell
    version map is invalid or missing.

 .../shell-extensions/gs-plugin-shell-extensions.c  |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/plugins/shell-extensions/gs-plugin-shell-extensions.c 
b/plugins/shell-extensions/gs-plugin-shell-extensions.c
index a7cbf6b..7c20235 100644
--- a/plugins/shell-extensions/gs-plugin-shell-extensions.c
+++ b/plugins/shell-extensions/gs-plugin-shell-extensions.c
@@ -263,6 +263,7 @@ gboolean
 gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
 {
        GsPluginData *priv = gs_plugin_get_data (plugin);
+       g_autofree gchar *name_owner = NULL;
        g_autoptr(GVariant) version = NULL;
 
        if (priv->proxy != NULL)
@@ -281,7 +282,8 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
        }
 
        /* not running under Shell */
-       if (g_dbus_proxy_get_name_owner (priv->proxy) == NULL) {
+       name_owner = g_dbus_proxy_get_name_owner (priv->proxy);
+       if (name_owner == NULL) {
                g_clear_object (&priv->proxy);
                return FALSE;
        }
@@ -456,7 +458,7 @@ gs_plugin_shell_extensions_parse_app (GsPlugin *plugin,
                                      JsonObject *json_app,
                                      GError **error)
 {
-       AsApp *app;
+       g_autoptr(AsApp) app = NULL;
        JsonObject *json_ver_map;
        const gchar *tmp;
 
@@ -536,7 +538,7 @@ gs_plugin_shell_extensions_parse_app (GsPlugin *plugin,
        as_app_add_metadata (app, "GnomeSoftware::OriginHostnameUrl",
                             SHELL_EXTENSIONS_API_URI);
 
-       return app;
+       return g_steal_pointer (&app);
 }
 
 static GPtrArray *


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