gdbusmessage: Clean the cached arg0 when setting the message body

We're now caching arg0 but such value is not cleared when a new body is
set as it's in the connection filter test cases where we've a leak as
highlighted by both valgrind and leak sanitizer
This commit is contained in:
Marco Trevisan (Treviño) 2024-05-08 22:53:51 +02:00 committed by Philip Withnall
parent d9d93579f0
commit fe89e9f3cb
No known key found for this signature in database
GPG Key ID: DCDF5885B1F3ED73

View File

@ -1155,10 +1155,12 @@ g_dbus_message_set_body (GDBusMessage *message,
if (message->body != NULL)
g_variant_unref (message->body);
g_clear_pointer (&message->arg0_cache, g_variant_unref);
if (body == NULL)
{
message->body = NULL;
message->arg0_cache = NULL;
g_dbus_message_set_signature (message, NULL);
}
else
@ -1172,8 +1174,6 @@ g_dbus_message_set_body (GDBusMessage *message,
if (g_variant_is_of_type (message->body, G_VARIANT_TYPE_TUPLE) &&
g_variant_n_children (message->body) > 0)
message->arg0_cache = g_variant_get_child_value (message->body, 0);
else
message->arg0_cache = NULL;
type_string = g_variant_get_type_string (body);
type_string_len = strlen (type_string);