gvariant: Fix memory leak on a TYPE_CHECK failure

This commit is contained in:
Egor Bychin 2021-10-11 14:20:26 +03:00
parent 0abf51e0de
commit 05dffc1a7f

View File

@ -800,7 +800,13 @@ g_variant_new_array (const GVariantType *child_type,
for (i = 0; i < n_children; i++) for (i = 0; i < n_children; i++)
{ {
TYPE_CHECK (children[i], child_type, NULL); if G_UNLIKELY (!g_variant_is_of_type (children[i], child_type))
{
while (i != 0)
g_variant_unref (my_children[--i]);
g_free (my_children);
g_return_val_if_fail (g_variant_is_of_type (children[i], child_type), NULL);
}
my_children[i] = g_variant_ref_sink (children[i]); my_children[i] = g_variant_ref_sink (children[i]);
trusted &= g_variant_is_trusted (children[i]); trusted &= g_variant_is_trusted (children[i]);
} }