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
This commit is contained in:
Owen W. Taylor 2012-01-05 13:58:30 -05:00
parent 0cfedcaad6
commit fa515328eb

View File

@ -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: