common: fixed a possible NULL pointer dereference in process tracking.
authorIsmo Puustinen <ismo.puustinen@intel.com>
Tue, 15 Oct 2013 10:17:53 +0000 (13:17 +0300)
committerIsmo Puustinen <ismo.puustinen@intel.com>
Tue, 15 Oct 2013 11:57:39 +0000 (14:57 +0300)
src/common/process.c

index 840480d..6f3d196 100644 (file)
@@ -917,12 +917,18 @@ mrp_pid_watch_t *mrp_pid_set_watch(pid_t pid, mrp_mainloop_t *ml,
         goto error;
     }
 
-    mrp_list_init(&client->hook);
     client->cb = cb;
     client->user_data = userdata;
     client->w = (mrp_pid_watch_t *) mrp_allocz(sizeof(mrp_pid_watch_t));
+
+    if (!client->w) {
+        mrp_free(nl_w);
+        goto error;
+    }
+
     client->w->pid = pid;
 
+    mrp_list_init(&client->hook);
     mrp_list_append(&nl_w->clients, &client->hook);
     nl_w->n_clients++;