From 15f4533742ad6aeab85ebb723ac8fca99c00e939 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Mon, 16 Nov 2009 13:32:40 +0000 Subject: [PATCH] Don't leak DBusGMethodInvocation for no-reply calls https://bugs.freedesktop.org/show_bug.cgi?id=25119 --- dbus/dbus-gobject.c | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-) diff --git a/dbus/dbus-gobject.c b/dbus/dbus-gobject.c index f0c4df8..98e381e 100644 --- a/dbus/dbus-gobject.c +++ b/dbus/dbus-gobject.c @@ -2478,7 +2478,7 @@ dbus_g_method_return (DBusGMethodInvocation *context, ...) * carry it over through the async invocation to here. */ if (!context->send_reply) - return; + goto out; reply = dbus_message_new_method_return (dbus_g_message_get_message (context->message)); out_sig = method_output_signature_from_object_info (context->object, context->method); @@ -2506,11 +2506,13 @@ dbus_g_method_return (DBusGMethodInvocation *context, ...) dbus_connection_send (dbus_g_connection_get_connection (context->connection), reply, NULL); dbus_message_unref (reply); + g_free (out_sig); + g_array_free (argsig, TRUE); + +out: dbus_g_connection_unref (context->connection); dbus_g_message_unref (context->message); g_free (context); - g_free (out_sig); - g_array_free (argsig, TRUE); } /** @@ -2525,15 +2527,16 @@ void dbus_g_method_return_error (DBusGMethodInvocation *context, const GError *error) { DBusMessage *reply; - + /* See comment in dbus_g_method_return */ if (!context->send_reply) - return; - + goto out; + reply = gerror_to_dbus_error_message (context->object, dbus_g_message_get_message (context->message), error); dbus_connection_send (dbus_g_connection_get_connection (context->connection), reply, NULL); dbus_message_unref (reply); - + +out: dbus_g_connection_unref (context->connection); dbus_g_message_unref (context->message); g_free (context); -- 1.6.4.3