Message ID | 20160719085432.4572-9-marcandre.lureau@redhat.com |
---|---|
State | New |
Headers | show |
On 07/19/2016 02:54 AM, marcandre.lureau@redhat.com wrote: > From: Marc-André Lureau <marcandre.lureau@redhat.com> > > qdist_init() allocates of entries, make sure we don't leak it. s/of // > > Spotted thanks to ASAN. > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> > --- > util/qdist.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > Reviewed-by: Eric Blake <eblake@redhat.com> > 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 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, from->n, > + sizeof(struct qdist_entry)); > to->n = from->n; > memcpy(to->entries, from->entries, sizeof(*to->entries) * to->n); > return; >
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 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, from->n, + sizeof(struct qdist_entry)); to->n = from->n; memcpy(to->entries, from->entries, sizeof(*to->entries) * to->n); return;