From 33d4518e50d45f1686c8c7fb8e5bc1230ecc8721 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Thu, 5 Jan 2012 13:58:30 -0500 Subject: [PATCH] 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 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/hotplug-sniffer/hotplug-sniffer.c b/src/hotplug-sniffer/hotplug-sniffer.c index 3363e8889..31b743d90 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: