Fix: lttng-ctl: use zmalloc(), missing OOM check
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 26 Nov 2014 17:37:21 +0000 (12:37 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 27 Nov 2014 20:27:22 +0000 (15:27 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/lib/lttng-ctl/lttng-ctl.c

index 23b84db4f9519e209d4477db2a6e645ac9c45157..ae9cede2588d0ba97218d43dc55b55e5fdeab139 100644 (file)
@@ -222,7 +222,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;
@@ -442,7 +442,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);
@@ -482,7 +486,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;
This page took 0.026718 seconds and 4 git commands to generate.