Received: from eggs.gnu.org ([2001:4830:134:3::10]:45662) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cyGJN-0000sb-VF for qemu-devel@nongnu.org; Wed, 12 Apr 2017 07:19:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cyGJK-0000BV-QS for qemu-devel@nongnu.org; Wed, 12 Apr 2017 07:19:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57060) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cyGJK-0000BO-Kx for qemu-devel@nongnu.org; Wed, 12 Apr 2017 07:19:42 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 66DEE19D00C for ; Wed, 12 Apr 2017 11:19:41 +0000 (UTC) From: Markus Armbruster References: <20170410142112.11550-1-marcandre.lureau@redhat.com> Date: Wed, 12 Apr 2017 13:19:37 +0200 In-Reply-To: <20170410142112.11550-1-marcandre.lureau@redhat.com> (=?utf-8?Q?=22Marc-Andr=C3=A9?= Lureau"'s message of "Mon, 10 Apr 2017 16:21:12 +0200") Message-ID: <8737ddna9i.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] test-keyval: fix leaks List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Cc: qemu-devel@nongnu.org Marc-Andr=C3=A9 Lureau writes: > Signed-off-by: Marc-Andr=C3=A9 Lureau > --- > tests/test-keyval.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/tests/test-keyval.c b/tests/test-keyval.c > index ba19560a22..141ee5d0c4 100644 > --- a/tests/test-keyval.c > +++ b/tests/test-keyval.c > @@ -628,6 +628,7 @@ static void test_keyval_visit_alternate(void) > visit_type_AltNumStr(v, "a", &ans, &error_abort); > g_assert_cmpint(ans->type, =3D=3D, QTYPE_QSTRING); > g_assert_cmpstr(ans->u.s, =3D=3D, "1"); > + qapi_free_AltNumStr(ans); > visit_type_AltNumInt(v, "a", &ani, &err); > error_free_or_abort(&err); > visit_end_struct(v, NULL); > @@ -649,11 +650,14 @@ static void test_keyval_visit_any(void) > visit_type_any(v, "a", &any, &error_abort); @any becomes a strong reference (qobject_input_type_any() increments the reference count). > qlist =3D qobject_to_qlist(any); Reference count unchanged. > g_assert(qlist); > + qobject_decref(any); Uh, this is unnecessarily dirty: you relinquish the reference before you're actually done with it. Works only because there's *another* reference hiding within @v. Let's move this ... > qstr =3D qobject_to_qstring(qlist_pop(qlist)); > g_assert_cmpstr(qstring_get_str(qstr), =3D=3D, "null"); > + QDECREF(qstr); > qstr =3D qobject_to_qstring(qlist_pop(qlist)); > g_assert_cmpstr(qstring_get_str(qstr), =3D=3D, "1"); > g_assert(qlist_empty(qlist)); > + QDECREF(qstr); ... here. Okay to do that on commit? > visit_check_struct(v, &error_abort); > visit_end_struct(v, NULL); > visit_free(v); With the reference counting cleaned up: Reviewed-by: Markus Armbruster