Fix: modprobe.c: fix tmp_list memory leak
[lttng-tools.git] / src / bin / lttng-sessiond / modprobe.c
index a9035dab5766d167d1f0646befb4569f0de05974..32c4210130d9227b1d4cb320cb66f80ccb6b28d5 100644 (file)
@@ -360,11 +360,11 @@ static int append_list_to_probes(const char *list)
 {
        char *next;
        int index = nr_probes, ret;
-       char *tmp_list;
+       char *tmp_list, *cur_list;
 
        assert(list);
 
-       tmp_list = strdup(list);
+       cur_list = tmp_list = strdup(list);
        if (!tmp_list) {
                PERROR("strdup temp list");
                return -ENOMEM;
@@ -374,11 +374,11 @@ static int append_list_to_probes(const char *list)
                size_t name_len;
                struct kern_modules_param *cur_mod;
 
-               next = strtok(tmp_list, ",");
+               next = strtok(cur_list, ",");
                if (!next) {
                        break;
                }
-               tmp_list = NULL;
+               cur_list = NULL;
 
                /* filter leading spaces */
                while (*next == ' ') {
@@ -395,7 +395,7 @@ static int append_list_to_probes(const char *list)
                /* Length 13 is "lttng-probe-" + \0 */
                name_len = strlen(next) + 13;
 
-               cur_mod = &probes[index];
+               cur_mod = &probes[index++];
                cur_mod->name = zmalloc(name_len);
                if (!cur_mod->name) {
                        PERROR("malloc probe list");
This page took 0.024885 seconds and 5 git commands to generate.