Fix: unchecked access to pids array
[lttng-tools.git] / src / lib / lttng-ctl / lttng-ctl.c
index f0b211c7b4a426e959855637ce23d7c08496143d..87081390175f346fb8d7b117e4439c6483d21faa 100644 (file)
@@ -2338,7 +2338,7 @@ int lttng_list_tracker_pids(struct lttng_handle *handle,
        int enabled = 1;
        struct lttcomm_session_msg lsm;
        size_t nr_pids;
-       int32_t *pids;
+       int32_t *pids = NULL;
 
        if (handle == NULL) {
                return -LTTNG_ERR_INVALID;
@@ -2355,6 +2355,9 @@ int lttng_list_tracker_pids(struct lttng_handle *handle,
                return ret;
        }
        nr_pids = ret / sizeof(int32_t);
+       if (nr_pids > 0 && !pids) {
+               return -LTTNG_ERR_UNK;
+       }
        if (nr_pids == 1 && pids[0] == -1) {
                free(pids);
                pids = NULL;
This page took 0.023613 seconds and 4 git commands to generate.