Fix: event copy constructor frees original event on error
[lttng-tools.git] / src / lib / lttng-ctl / event.c
index 046028cd219a46b25866770c1d8c96b8405092a2..5785345cd1bdb703da157f428da38733aefc582f 100644 (file)
@@ -60,7 +60,7 @@ struct lttng_event *lttng_event_copy(const struct lttng_event *event)
        struct lttng_event_extended *new_event_extended;
 
        new_event = zmalloc(sizeof(*event));
-       if (!event) {
+       if (!new_event) {
                PERROR("Error allocating event structure");
                goto end;
        }
@@ -82,7 +82,7 @@ struct lttng_event *lttng_event_copy(const struct lttng_event *event)
 end:
        return new_event;
 error:
-       free(event);
+       free(new_event);
        goto end;
 }
 
@@ -197,8 +197,8 @@ end:
        return ret;
 }
 
-struct lttng_userspace_probe_location *
-lttng_event_get_userspace_probe_location(struct lttng_event *event)
+const struct lttng_userspace_probe_location *
+lttng_event_get_userspace_probe_location(const struct lttng_event *event)
 {
        struct lttng_userspace_probe_location *probe_location = NULL;
        struct lttng_event_extended *event_extended;
This page took 0.025462 seconds and 4 git commands to generate.