From: "Emilio G. Cota" <cota@braap.org>
To: QEMU Developers <qemu-devel@nongnu.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Richard Henderson <rth@twiddle.net>,
Peter Maydell <peter.maydell@linaro.org>,
Changlong Xie <xiecl.fnst@cn.fujitsu.com>
Subject: [Qemu-devel] [PATCH 1/3] qdist: fix memory leak during binning
Date: Mon, 25 Jul 2016 11:03:43 -0400 [thread overview]
Message-ID: <1469459025-23606-2-git-send-email-cota@braap.org> (raw)
In-Reply-To: <1469459025-23606-1-git-send-email-cota@braap.org>
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 <cota@braap.org>
---
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.5.0
next prev parent reply other threads:[~2016-07-25 15:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-25 15:03 [Qemu-devel] [PATCH 0/3] qdist fixes Emilio G. Cota
2016-07-25 15:03 ` Emilio G. Cota [this message]
2016-07-26 8:42 ` [Qemu-devel] [PATCH 1/3] qdist: fix memory leak during binning Marc-André Lureau
2016-07-25 15:03 ` [Qemu-devel] [PATCH 2/3] qdist: use g_realloc_n instead of g_realloc Emilio G. Cota
2016-07-26 8:48 ` Marc-André Lureau
2016-07-25 15:03 ` [Qemu-devel] [PATCH 3/3] qdist: return "(empty)" instead of NULL when printing an empty dist Emilio G. Cota
2016-08-01 8:11 ` [Qemu-devel] [PATCH 0/3] qdist fixes Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1469459025-23606-2-git-send-email-cota@braap.org \
--to=cota@braap.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
--cc=xiecl.fnst@cn.fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).