From fa29ba839dc350d1e86ecc542a66b59a586e1ec1 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Wed, 17 Feb 2016 19:21:26 -0500 Subject: [PATCH] ir: bt_ctf_stream_append_event(): do not append event with parent MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- formats/ctf/ir/stream.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/formats/ctf/ir/stream.c b/formats/ctf/ir/stream.c index 7136b26b..e9ff83e4 100644 --- a/formats/ctf/ir/stream.c +++ b/formats/ctf/ir/stream.c @@ -563,6 +563,19 @@ int bt_ctf_stream_append_event(struct bt_ctf_stream *stream, goto end; } + /* + * The event is not supposed to have a parent stream at this + * point. The only other way an event can have a parent stream + * is if it was assigned when setting a packet to the event, + * in which case the packet's stream is not a writer stream, + * and thus the user is trying to append an event which belongs + * to another stream. + */ + if (event->base.parent) { + ret = -1; + goto end; + } + bt_object_set_parent(event, stream); ret = bt_ctf_event_populate_event_header(event); if (ret) { -- 2.34.1