]> Git Repo - qemu.git/commitdiff
qdist: fix memory leak during binning
authorEmilio G. Cota <[email protected]>
Mon, 25 Jul 2016 15:03:43 +0000 (11:03 -0400)
committerPaolo Bonzini <[email protected]>
Tue, 2 Aug 2016 10:03:58 +0000 (12:03 +0200)
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 <[email protected]>
Message-Id: <1469459025[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
util/qdist.c

index 56f573837d49affb4c50d1f124a545deeed029b1..eb2236cdc85ac4594e5e385128a9b32c69f70268 100644 (file)
@@ -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;
This page took 0.028086 seconds and 4 git commands to generate.