[glib/glib-2-70: 14/18] gvariant: Fix memory leak on a TYPE_CHECK failure
- From: Sebastian Dröge <sdroege src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/glib-2-70: 14/18] gvariant: Fix memory leak on a TYPE_CHECK failure
- Date: Tue, 19 Oct 2021 06:21:26 +0000 (UTC)
commit d25f5c0dfbea30a40a0e8b425af82c20f2b35877
Author: Egor Bychin <e bychin drweb com>
Date: Mon Oct 11 14:20:26 2021 +0300
gvariant: Fix memory leak on a TYPE_CHECK failure
glib/gvariant.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/glib/gvariant.c b/glib/gvariant.c
index a9bb99c64..4a9704c19 100644
--- a/glib/gvariant.c
+++ b/glib/gvariant.c
@@ -800,7 +800,13 @@ g_variant_new_array (const GVariantType *child_type,
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]);
trusted &= g_variant_is_trusted (children[i]);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]