Received: from eggs.gnu.org ([2001:4830:134:3::10]:35893) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUfXd-0006bh-MS for qemu-devel@nongnu.org; Tue, 02 Aug 2016 15:39:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bUfXc-0003XE-QC for qemu-devel@nongnu.org; Tue, 02 Aug 2016 15:39:53 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:35546) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUfXc-0003X2-Jp for qemu-devel@nongnu.org; Tue, 02 Aug 2016 15:39:52 -0400 Received: by mail-wm0-x241.google.com with SMTP id i5so32588881wmg.2 for ; Tue, 02 Aug 2016 12:39:52 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Tue, 2 Aug 2016 21:39:20 +0200 Message-Id: <1470166775-3671-11-git-send-email-pbonzini@redhat.com> In-Reply-To: <1470166775-3671-1-git-send-email-pbonzini@redhat.com> References: <1470166775-3671-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 10/25] qdist: fix memory leak during binning List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Emilio G. Cota" From: "Emilio G. Cota" In qdist_bin__internal(), to->entries is initialized to a 1-element array, which we then leak when n == from->n. Fix it. Signed-off-by: Emilio G. Cota Message-Id: <1469459025-23606-2-git-send-email-cota@braap.org> Signed-off-by: Paolo Bonzini --- util/qdist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/qdist.c b/util/qdist.c index 56f5738..eb2236c 100644 --- a/util/qdist.c +++ b/util/qdist.c @@ -188,7 +188,7 @@ void qdist_bin__internal(struct qdist *to, const struct qdist *from, size_t n) } } /* they're equally spaced, so copy the dist and bail out */ - to->entries = g_new(struct qdist_entry, from->n); + to->entries = g_realloc_n(to->entries, n, sizeof(*to->entries)); to->n = from->n; memcpy(to->entries, from->entries, sizeof(*to->entries) * to->n); return; -- 2.7.4