X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=formats%2Fctf%2Fir%2Fstream.c;h=8c5a9877fb3dceae1aadf01aae9476a868d93a0a;hb=c44c3e709f9e95a847e9502c5297234aa1f01577;hp=f2706169bd488a05264efcec5d2b336c62ef20e8;hpb=b71d729878967a4c0fb839fdea8d034cf90a1d1f;p=babeltrace.git diff --git a/formats/ctf/ir/stream.c b/formats/ctf/ir/stream.c index f2706169..8c5a9877 100644 --- a/formats/ctf/ir/stream.c +++ b/formats/ctf/ir/stream.c @@ -563,16 +563,29 @@ 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) { - goto end; + goto error; } /* Make sure the various scopes of the event are set */ ret = bt_ctf_event_validate(event); if (ret) { - goto end; + goto error; } /* Save the new event and freeze it */ @@ -586,14 +599,17 @@ int bt_ctf_stream_append_event(struct bt_ctf_stream *stream, * longer needed. */ bt_put(event->event_class); + end: - if (ret) { - /* - * Orphan the event; we were not succesful in associating it to - * a stream. - */ - bt_object_set_parent(event, NULL); - } + return ret; + +error: + /* + * Orphan the event; we were not successful in associating it to + * a stream. + */ + bt_object_set_parent(event, NULL); + return ret; } @@ -917,9 +933,9 @@ void bt_ctf_stream_destroy(struct bt_object *obj) if (stream->name) { g_string_free(stream->name, TRUE); } + bt_put(stream->packet_header); bt_put(stream->packet_context); - bt_put(stream->event_context); g_free(stream); }