From: David Goulet Date: Wed, 30 Nov 2011 16:30:14 +0000 (-0500) Subject: Fix realloc invalid next size X-Git-Tag: v2.0-pre15~54 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=2f2215907a630529cfa2f85d3d143c889e4fc021;p=lttng-tools.git Fix realloc invalid next size Reported-by: Tan Dung Le Tran Signed-off-by: David Goulet --- diff --git a/lttng-sessiond/kernel.c b/lttng-sessiond/kernel.c index c734e889b..16334a83b 100644 --- a/lttng-sessiond/kernel.c +++ b/lttng-sessiond/kernel.c @@ -582,7 +582,7 @@ ssize_t kernel_list_events(int tracer_fd, struct lttng_event **events) nbmem + KERNEL_EVENT_LIST_SIZE); /* Adding the default size again */ nbmem += KERNEL_EVENT_LIST_SIZE; - elist = realloc(elist, nbmem); + elist = realloc(elist, nbmem * sizeof(struct lttng_event)); if (elist == NULL) { perror("realloc list events"); count = -ENOMEM; diff --git a/lttng-sessiond/ust-app.c b/lttng-sessiond/ust-app.c index 047225143..1afb6d199 100644 --- a/lttng-sessiond/ust-app.c +++ b/lttng-sessiond/ust-app.c @@ -1185,7 +1185,7 @@ int ust_app_list_events(struct lttng_event **events) DBG2("Reallocating event list from %zu to %zu bytes", nbmem, nbmem + UST_APP_EVENT_LIST_SIZE); nbmem += UST_APP_EVENT_LIST_SIZE; - tmp = realloc(tmp, nbmem); + tmp = realloc(tmp, nbmem * sizeof(struct lttng_event)); if (tmp == NULL) { PERROR("realloc ust app events"); ret = -ENOMEM;