Fix: tracker: NULL pointer dereference after NULL check
[lttng-tools.git] / src / common / tracker.c
index 532a924b56a772b3d55d11e611028ebf7267a7fe..29249d528bc8da1f1a7b71e00381cc24b65d1678 100644 (file)
@@ -85,6 +85,7 @@ enum lttng_error_code process_attr_value_from_comm(
                name = strdup(value_view->data);
                if (!name) {
                        ret = LTTNG_ERR_NOMEM;
+                       goto error;
                }
        }
 
@@ -102,10 +103,12 @@ enum lttng_error_code process_attr_value_from_comm(
        }
 
        /* Only expect a payload for name value types. */
-       if (is_value_type_name(value_type) && value_view->size == 0) {
+       if (is_value_type_name(value_type) &&
+                       (!value_view || value_view->size == 0)) {
                ret = LTTNG_ERR_INVALID_PROTOCOL;
                goto error;
-       } else if (!is_value_type_name(value_type) && value_view->size != 0) {
+       } else if (!is_value_type_name(value_type) && value_view &&
+                       value_view->size != 0) {
                ret = LTTNG_ERR_INVALID_PROTOCOL;
                goto error;
        }
@@ -173,6 +176,7 @@ enum lttng_error_code process_attr_value_from_comm(
 
        *_value = value;
        value = NULL;
+       free(name);
        return LTTNG_OK;
 error:
        free(name);
This page took 0.023576 seconds and 4 git commands to generate.