Fix: ensure that a stream class is not associated to a trace
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 3 Nov 2016 18:23:51 +0000 (14:23 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 27 May 2017 18:09:06 +0000 (14:09 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
formats/ctf/ir/trace.c

index 4476c8f057baa257775622ed72a7a139d848298f..55967275a84d56fea4202c06b96caee745db697f 100644 (file)
@@ -430,12 +430,20 @@ int bt_ctf_trace_add_stream_class(struct bt_ctf_trace *trace,
        struct bt_ctf_field_type *stream_event_ctx_type = NULL;
        int event_class_count;
        struct bt_ctf_clock *clock_to_add_to_trace = NULL;
+       struct bt_ctf_trace *current_parent_trace = NULL;
 
        if (!trace || !stream_class) {
                ret = -1;
                goto end;
        }
 
+       current_parent_trace = bt_ctf_stream_class_get_trace(stream_class);
+       if (current_parent_trace) {
+               /* Stream class is already associated to a trace, abort. */
+               ret = -1;
+               goto end;
+       }
+
        event_class_count =
                bt_ctf_stream_class_get_event_class_count(stream_class);
        assert(event_class_count >= 0);
@@ -668,6 +676,7 @@ end:
        g_free(ec_validation_outputs);
        bt_ctf_validation_output_put_types(&trace_sc_validation_output);
        BT_PUT(clock_to_add_to_trace);
+       bt_put(current_parent_trace);
        assert(!packet_header_type);
        assert(!packet_context_type);
        assert(!event_header_type);
This page took 0.024629 seconds and 4 git commands to generate.