Fix: trace_collection_add() add after check
[babeltrace.git] / lib / trace-collection.c
index 608a6e458093f7f751a0807112f1c0b7ffa98c00..c5c875c975d64d4d76bd83822a12034218e0e528 100644 (file)
@@ -164,8 +164,6 @@ int bt_trace_collection_add(struct trace_collection *tc,
                return -EINVAL;
 
        trace = container_of(td, struct ctf_trace, parent);
-       g_ptr_array_add(tc->array, td);
-       trace->collection = tc;
 
        if (tc->array->len > 1) {
                struct clock_match clock_match = {
@@ -187,6 +185,9 @@ int bt_trace_collection_add(struct trace_collection *tc,
                }
        }
 
+       g_ptr_array_add(tc->array, td);
+       trace->collection = tc;
+
        {
                struct clock_match clock_match = {
                        .clocks = tc->clocks,
This page took 0.02462 seconds and 4 git commands to generate.