From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwSKv-0007v2-SJ for qemu-devel@nongnu.org; Tue, 18 Oct 2016 07:13:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bwSKq-0004V7-WE for qemu-devel@nongnu.org; Tue, 18 Oct 2016 07:13:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34878) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bwSKq-0004Up-OL for qemu-devel@nongnu.org; Tue, 18 Oct 2016 07:13:32 -0400 References: <1476782267-2602-1-git-send-email-ptoscano@redhat.com> From: Eric Blake Message-ID: Date: Tue, 18 Oct 2016 06:13:30 -0500 MIME-Version: 1.0 In-Reply-To: <1476782267-2602-1-git-send-email-ptoscano@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="h2OpwG8XjmBAW3kkulWJTkpWpWk67HWBu" Subject: Re: [Qemu-devel] [PATCH] qapi: fix memory leak in QmpOutputVisitor List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pino Toscano , qemu-devel@nongnu.org Cc: armbru@redhat.com, mdroth@linux.vnet.ibm.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --h2OpwG8XjmBAW3kkulWJTkpWpWk67HWBu From: Eric Blake To: Pino Toscano , qemu-devel@nongnu.org Cc: armbru@redhat.com, mdroth@linux.vnet.ibm.com Message-ID: Subject: Re: [Qemu-devel] [PATCH] qapi: fix memory leak in QmpOutputVisitor References: <1476782267-2602-1-git-send-email-ptoscano@redhat.com> In-Reply-To: <1476782267-2602-1-git-send-email-ptoscano@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 10/18/2016 04:17 AM, Pino Toscano wrote: > qmp_output_start_struct() and qmp_output_start_list() create a new > QObject (QDict, QList) and push it to the stack of the QmpOutputVisitor= , > where it is saved as 'value'. When freeing the iterator in > qmp_output_free(), these values are never freed properly. Do any of the tests (perhaps run under valgrind) show this leak? If not, maybe we should enhance their coverage. >=20 > The simple solution is to qobject_decref() them. > --- > qapi/qmp-output-visitor.c | 1 + > 1 file changed, 1 insertion(+) Reviewed-by: Eric Blake >=20 > diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c > index 9e3b67c..eedf256 100644 > --- a/qapi/qmp-output-visitor.c > +++ b/qapi/qmp-output-visitor.c > @@ -220,6 +220,7 @@ static void qmp_output_free(Visitor *v) > while (!QSLIST_EMPTY(&qov->stack)) { > e =3D QSLIST_FIRST(&qov->stack); > QSLIST_REMOVE_HEAD(&qov->stack, node); > + qobject_decref(e->value); > g_free(e); > } > =20 >=20 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --h2OpwG8XjmBAW3kkulWJTkpWpWk67HWBu Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJYBgPaAAoJEKeha0olJ0Nq32UH/3XUNwzHiIvrD6beetCmudac D4V8Lu3tIFX1G0fY7jW32XopKAduWEgTCah2J4tBHRd5eW4+ZRSOeLJ/Pumdn/nK QG/ATY9xX3xgvpT0o2s9hppuRtaqf52nQdeq+rh9NHrEhwKj1F0wmPUFZfaiN5ze c1MUEtXI/pCjpS1s/29QvUyzkHpQRzXkTE3iHwsoLSyQW3MHJuRdBQ8g9Vpw35pb 5FgsO5HMJ6luanm0O2xQEHxoyIOO9AQ5c1JfJrJxWnPpbnYi7YODMK6CIwA/jVGl 9LGATBkTBN5DGHhPMZUNFisr2IwXx7/+CZin/FwO/mmmdxYlcSYShuLA84gh7Ig= =9zOU -----END PGP SIGNATURE----- --h2OpwG8XjmBAW3kkulWJTkpWpWk67HWBu--