mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 23:43:39 +02:00
gdbusmethodinvocation: Fix a leak on an early return path
When doing an early return from `g_dbus_method_invocation_return_*()` due to passing in the wrong type (or no return value when one was expected), the parameters were not correctly sunk and were leaked. Fix that. A unit test will be added in a following commit. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Coverity CID: #1474536
This commit is contained in:
@@ -397,14 +397,7 @@ g_dbus_method_invocation_return_value_internal (GDBusMethodInvocation *invocatio
|
|||||||
g_return_if_fail ((parameters == NULL) || g_variant_is_of_type (parameters, G_VARIANT_TYPE_TUPLE));
|
g_return_if_fail ((parameters == NULL) || g_variant_is_of_type (parameters, G_VARIANT_TYPE_TUPLE));
|
||||||
|
|
||||||
if (g_dbus_message_get_flags (invocation->message) & G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED)
|
if (g_dbus_message_get_flags (invocation->message) & G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED)
|
||||||
{
|
goto out;
|
||||||
if (parameters != NULL)
|
|
||||||
{
|
|
||||||
g_variant_ref_sink (parameters);
|
|
||||||
g_variant_unref (parameters);
|
|
||||||
}
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parameters == NULL)
|
if (parameters == NULL)
|
||||||
parameters = g_variant_new_tuple (NULL, 0);
|
parameters = g_variant_new_tuple (NULL, 0);
|
||||||
@@ -508,7 +501,7 @@ g_dbus_method_invocation_return_value_internal (GDBusMethodInvocation *invocatio
|
|||||||
}
|
}
|
||||||
|
|
||||||
reply = g_dbus_message_new_method_reply (invocation->message);
|
reply = g_dbus_message_new_method_reply (invocation->message);
|
||||||
g_dbus_message_set_body (reply, parameters);
|
g_dbus_message_set_body (reply, g_steal_pointer (¶meters));
|
||||||
|
|
||||||
#ifdef G_OS_UNIX
|
#ifdef G_OS_UNIX
|
||||||
if (fd_list != NULL)
|
if (fd_list != NULL)
|
||||||
@@ -525,6 +518,12 @@ g_dbus_method_invocation_return_value_internal (GDBusMethodInvocation *invocatio
|
|||||||
g_object_unref (reply);
|
g_object_unref (reply);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
if (parameters != NULL)
|
||||||
|
{
|
||||||
|
g_variant_ref_sink (parameters);
|
||||||
|
g_variant_unref (parameters);
|
||||||
|
}
|
||||||
|
|
||||||
g_object_unref (invocation);
|
g_object_unref (invocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user