From 2f2215907a630529cfa2f85d3d143c889e4fc021 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Wed, 30 Nov 2011 11:30:14 -0500 Subject: [PATCH] Fix realloc invalid next size Reported-by: Tan Dung Le Tran Signed-off-by: David Goulet --- lttng-sessiond/kernel.c | 2 +- lttng-sessiond/ust-app.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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; -- 2.34.1