From 37d9b0c6995f97ea0f744650aaf5179081f878ba Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 15 Nov 2017 12:26:26 +0000 Subject: [PATCH] gdbusutils: Fix a memory leak in g_dbus_gvalue_to_gvariant() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit g_variant_get_normal_form() doesn’t necessarily return a floating GVariant, so we have to take, rather than sink, the ref. This fixes a lot of leaks with gdbus-codegen-generated code. Signed-off-by: Philip Withnall https://bugzilla.gnome.org/show_bug.cgi?id=741167 --- gio/gdbusutils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gio/gdbusutils.c b/gio/gdbusutils.c index ff036c765..bfca02d6f 100644 --- a/gio/gdbusutils.c +++ b/gio/gdbusutils.c @@ -685,7 +685,7 @@ g_dbus_gvalue_to_gvariant (const GValue *gvalue, { GVariant *untrusted_empty; untrusted_empty = g_variant_new_from_data (type, NULL, 0, FALSE, NULL, NULL); - ret = g_variant_ref_sink (g_variant_get_normal_form (untrusted_empty)); + ret = g_variant_take_ref (g_variant_get_normal_form (untrusted_empty)); g_variant_unref (untrusted_empty); }