From: Mathieu Desnoyers Date: Wed, 26 Nov 2014 17:37:21 +0000 (-0500) Subject: Fix: lttng-ctl: use zmalloc(), missing OOM check X-Git-Tag: v2.6.0-rc4~17 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=6b25c80050e97c9167b56c46198bc186cb92eafe;p=lttng-tools.git Fix: lttng-ctl: use zmalloc(), missing OOM check Signed-off-by: Mathieu Desnoyers Signed-off-by: Jérémie Galarneau --- diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index ff57a0d1a..38cc79f3c 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -224,7 +224,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; @@ -444,7 +444,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); @@ -484,7 +488,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;