From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45024) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPc1s-0007mq-Vq for qemu-devel@nongnu.org; Tue, 19 Jul 2016 16:54:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPc1n-0008RX-5s for qemu-devel@nongnu.org; Tue, 19 Jul 2016 16:54:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39864) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPc1m-0008RP-Tf for qemu-devel@nongnu.org; Tue, 19 Jul 2016 16:54:07 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 60B6263308 for ; Tue, 19 Jul 2016 20:54:06 +0000 (UTC) References: <20160719085432.4572-1-marcandre.lureau@redhat.com> <20160719085432.4572-9-marcandre.lureau@redhat.com> From: Eric Blake Message-ID: <578E936D.2040708@redhat.com> Date: Tue, 19 Jul 2016 14:54:05 -0600 MIME-Version: 1.0 In-Reply-To: <20160719085432.4572-9-marcandre.lureau@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="eR8rJHV0dDUW9AKJf6eXNj2N3deLifCP0" Subject: Re: [Qemu-devel] [PATCH 08/37] qdist: fix entries memory leak List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: marcandre.lureau@redhat.com, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --eR8rJHV0dDUW9AKJf6eXNj2N3deLifCP0 From: Eric Blake To: marcandre.lureau@redhat.com, qemu-devel@nongnu.org Message-ID: <578E936D.2040708@redhat.com> Subject: Re: [Qemu-devel] [PATCH 08/37] qdist: fix entries memory leak References: <20160719085432.4572-1-marcandre.lureau@redhat.com> <20160719085432.4572-9-marcandre.lureau@redhat.com> In-Reply-To: <20160719085432.4572-9-marcandre.lureau@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 07/19/2016 02:54 AM, marcandre.lureau@redhat.com wrote: > From: Marc-Andr=C3=A9 Lureau >=20 > qdist_init() allocates of entries, make sure we don't leak it. s/of // >=20 > Spotted thanks to ASAN. >=20 > Signed-off-by: Marc-Andr=C3=A9 Lureau > --- > util/qdist.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) >=20 Reviewed-by: Eric Blake > diff --git a/util/qdist.c b/util/qdist.c > index 56f5738..e94cf46 100644 > --- a/util/qdist.c > +++ b/util/qdist.c > @@ -188,7 +188,8 @@ void qdist_bin__internal(struct qdist *to, const st= ruct qdist *from, size_t n) > } > } > /* they're equally spaced, so copy the dist and bail out */ > - to->entries =3D g_new(struct qdist_entry, from->n); > + to->entries =3D g_realloc_n(to->entries, from->n, > + sizeof(struct qdist_entry)); > to->n =3D from->n; > memcpy(to->entries, from->entries, sizeof(*to->entries) * to->= n); > return; >=20 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --eR8rJHV0dDUW9AKJf6eXNj2N3deLifCP0 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/ iQEcBAEBCAAGBQJXjpNtAAoJEKeha0olJ0NqAT0IAJ9FY5Vg9N6yNXiqOy9VEkpe p5Hw3a6QxPmaZC2RV1II30xaXpMRDmGsGIMM1tBtXYWEIrUa4XlXDU24+cJf4LTc uC4HU6AtAWE+mq1D93XPHTw+3S3qrS043q1z9P91fllZ619JekqPAshtjMoePHNr QRXxjj1YVaCoilwOIn4RSlfYJ/m0rONOMDe5ABGuCR6zmbgtAdmGprBmPC6oicuD cpZ1VK0EBL74jLNVza55KOPCJECw02NvkQsnbIro/+5bj+x9VXTFI97r9N9inZJQ ZDM7b+DNvuDlSGafPJBo6Wc+jy2BoKQwBUg3BrrNy1TQvY8OsL1/1p6Dhkus2xM= =POwX -----END PGP SIGNATURE----- --eR8rJHV0dDUW9AKJf6eXNj2N3deLifCP0--