[gnome-shell] hotplug-sniffer: fix double free when setting D-Bus return value



commit 33d4518e50d45f1686c8c7fb8e5bc1230ecc8721
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Thu Jan 5 13:58:30 2012 -0500

    hotplug-sniffer: fix double free when setting D-Bus return value
    
    g_dbus_method_invocation_return_value() adopts a floating reference,
    so we don't also need to unreference it; fix by replacing the code
    using a more compact form using the ^ convenience character in
    GVariant type specifications. (Thanks to Ryan Lortie for the
    suggestion.)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=667378

 src/hotplug-sniffer/hotplug-sniffer.c |   15 ++-------------
 1 files changed, 2 insertions(+), 13 deletions(-)
---
diff --git a/src/hotplug-sniffer/hotplug-sniffer.c b/src/hotplug-sniffer/hotplug-sniffer.c
index 3363e88..31b743d 100644
--- a/src/hotplug-sniffer/hotplug-sniffer.c
+++ b/src/hotplug-sniffer/hotplug-sniffer.c
@@ -114,10 +114,7 @@ sniff_async_ready_cb (GObject *source,
 {
   InvocationData *data = user_data;
   gchar **types;
-  gint idx;
   GError *error = NULL;
-  GVariantBuilder *builder;
-  GVariant *result;
 
   types = shell_mime_sniffer_sniff_finish (SHELL_MIME_SNIFFER (source),
                                            res, &error);
@@ -129,16 +126,8 @@ sniff_async_ready_cb (GObject *source,
       goto out;
     }
 
-  builder = g_variant_builder_new (G_VARIANT_TYPE ("as"));
-
-  for (idx = 0; types[idx] != NULL; idx++)
-    g_variant_builder_add (builder, "s", types[idx]);
-
-  result = g_variant_new ("(as)", builder);
-  g_dbus_method_invocation_return_value (data->invocation, result);
-
-  g_variant_unref (result);
-  g_variant_builder_unref (builder);
+  g_dbus_method_invocation_return_value (data->invocation,
+                                         g_variant_new ("(^as)", types));
   g_strfreev (types);
 
  out:



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