From 3f451dc03f23277be8198628b817abdc3a19bd91 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 26 Nov 2014 12:37:21 -0500 Subject: [PATCH] Fix: lttng-ctl: use zmalloc(), missing OOM check MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Mathieu Desnoyers Signed-off-by: Jérémie Galarneau --- src/lib/lttng-ctl/lttng-ctl.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index d573eb0be..004196965 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -226,7 +226,7 @@ int lttng_check_tracing_group(void) } /* Alloc group list of the right size */ - grp_list = malloc(grp_list_size * sizeof(gid_t)); + grp_list = zmalloc(grp_list_size * sizeof(gid_t)); if (!grp_list) { perror("malloc"); goto end; @@ -446,7 +446,11 @@ int lttng_ctl_ask_sessiond_varlen(struct lttcomm_session_msg *lsm, goto end; } - data = (void*) malloc(size); + data = zmalloc(size); + if (!data) { + ret = -ENOMEM; + goto end; + } /* Get payload data */ ret = recv_data_sessiond(data, size); @@ -486,7 +490,7 @@ struct lttng_handle *lttng_create_handle(const char *session_name, goto end; } - handle = malloc(sizeof(struct lttng_handle)); + handle = zmalloc(sizeof(struct lttng_handle)); if (handle == NULL) { PERROR("malloc handle"); goto end; -- 2.34.1