[gnome-control-center] shell: Fix GVariantBuilder leak



commit c33ac8bca97f6b844f54861dd1cdad241d5eedfa
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Tue Jun 23 10:29:50 2015 +0200

    shell: Fix GVariantBuilder leak
    
    When a GVariantBuilder is created with g_variant_builder_new(), it must
    be unref'ed with g_variant_builder_unref() when no longer needed. In
    this case, we can just use a local stack-allocated GVariantBuilder to
    avoid the leak.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=751597

 shell/cc-application.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/shell/cc-application.c b/shell/cc-application.c
index 936f902..353f09c 100644
--- a/shell/cc-application.c
+++ b/shell/cc-application.c
@@ -216,7 +216,7 @@ cc_application_command_line (GApplication *application,
       const char *start_id;
       GError *err = NULL;
       GVariant *parameters;
-      GVariantBuilder *builder;
+      GVariantBuilder builder;
       int i;
 
       start_id = start_panels[0];
@@ -226,10 +226,11 @@ cc_application_command_line (GApplication *application,
       else
         g_debug ("No extra argument");
 
-      builder = g_variant_builder_new (G_VARIANT_TYPE ("av"));
+      g_variant_builder_init (&builder, G_VARIANT_TYPE ("av"));
+
       for (i = 1; start_panels[i] != NULL; i++)
-        g_variant_builder_add (builder, "v", g_variant_new_string (start_panels[i]));
-      parameters = g_variant_builder_end (builder);
+        g_variant_builder_add (&builder, "v", g_variant_new_string (start_panels[i]));
+      parameters = g_variant_builder_end (&builder);
       if (!cc_shell_set_active_panel_from_id (CC_SHELL (self->priv->window), start_id, parameters, &err))
         {
           g_warning ("Could not load setting panel \"%s\": %s", start_id,


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