From 2789e5d9b2cbbe16af62b703981719b9cae8470f Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 3 Nov 2016 14:23:51 -0400 Subject: [PATCH] Fix: ensure that a stream class is not associated to a trace MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- formats/ctf/ir/trace.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/formats/ctf/ir/trace.c b/formats/ctf/ir/trace.c index 4476c8f0..55967275 100644 --- a/formats/ctf/ir/trace.c +++ b/formats/ctf/ir/trace.c @@ -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); -- 2.34.1