diff options
author | Emilio G. Cota <cota@braap.org> | 2016-07-25 11:03:43 -0400 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-08-02 12:03:58 +0200 |
commit | f9dbc19e8bf58d0cbc830083352475bb16f315c4 (patch) | |
tree | 667a9855db8de72822a5776dcc032ff10aefab7b /util | |
parent | ba03584f4f88082368b2562e515c3d60421b68ce (diff) | |
download | qemu-f9dbc19e8bf58d0cbc830083352475bb16f315c4.tar.gz qemu-f9dbc19e8bf58d0cbc830083352475bb16f315c4.tar.bz2 qemu-f9dbc19e8bf58d0cbc830083352475bb16f315c4.zip |
qdist: fix memory leak during binning
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>
Message-Id: <1469459025-23606-2-git-send-email-cota@braap.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'util')
-rw-r--r-- | util/qdist.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/util/qdist.c b/util/qdist.c index 56f573837d..eb2236cdc8 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; |