From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46496) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPQnv-0000HC-7n for qemu-devel@nongnu.org; Tue, 19 Jul 2016 04:55:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPQnu-0007X3-9d for qemu-devel@nongnu.org; Tue, 19 Jul 2016 04:55:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37978) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPQnu-0007Wy-4I for qemu-devel@nongnu.org; Tue, 19 Jul 2016 04:55:02 -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 A2EF67F6A8 for ; Tue, 19 Jul 2016 08:55:01 +0000 (UTC) From: marcandre.lureau@redhat.com Date: Tue, 19 Jul 2016 12:54:03 +0400 Message-Id: <20160719085432.4572-9-marcandre.lureau@redhat.com> In-Reply-To: <20160719085432.4572-1-marcandre.lureau@redhat.com> References: <20160719085432.4572-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 08/37] qdist: fix entries memory leak List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= From: Marc-Andr=C3=A9 Lureau qdist_init() allocates of entries, make sure we don't leak it. Spotted thanks to ASAN. Signed-off-by: Marc-Andr=C3=A9 Lureau --- util/qdist.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 stru= ct 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 2.9.0