From 1b66bf4122a1e5b881b2ed132e79beb5c54b75e4 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 10 Dec 2024 15:59:04 +0000 Subject: [PATCH] =?UTF-8?q?gdbusconnection:=20Add=20a=20comment=20explaini?= =?UTF-8?q?ng=20why=20an=20invocation=20is=20=E2=80=98leaked=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s not leaked, it’s transferred forwards to the eventual `g_dbus_method_invocation_return_*()` call. Signed-off-by: Philip Withnall Helps: #3559 --- gio/gdbusconnection.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gio/gdbusconnection.c b/gio/gdbusconnection.c index 3587a0928..a4b57cfc6 100644 --- a/gio/gdbusconnection.c +++ b/gio/gdbusconnection.c @@ -5950,6 +5950,11 @@ register_with_closures_on_method_call (GDBusConnection *connection, g_value_set_variant (¶ms[5], parameters); g_value_init (¶ms[6], G_TYPE_DBUS_METHOD_INVOCATION); + /* NOTE: This is deliberately *not* g_value_take_object(). A reference to + * `invocation` is transferred in to this function, and it needs to be + * transferred onwards to the `g_dbus_method_invocation_return_*()` method + * call which must eventually happen (either in the closure function, or in + * a delayed consequence from it). Changing this will break API. */ g_value_set_object (¶ms[6], invocation); g_closure_invoke (data->method_call_closure, NULL, G_N_ELEMENTS (params), params, NULL);