From: Jérémie Galarneau Date: Fri, 27 Jan 2017 05:41:39 +0000 (-0500) Subject: Writer: don't allow more than one packet without packet context X-Git-Tag: v2.0.0-pre1~550 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=664f50c80ff21a798a2c9dfd9c601529a63dda26 Writer: don't allow more than one packet without packet context Signed-off-by: Jérémie Galarneau --- diff --git a/formats/ctf/ir/stream.c b/formats/ctf/ir/stream.c index 979d40e9..e6e7575a 100644 --- a/formats/ctf/ir/stream.c +++ b/formats/ctf/ir/stream.c @@ -884,6 +884,16 @@ int bt_ctf_stream_flush(struct bt_ctf_stream *stream) goto end; } + if (!stream->packet_context && stream->flushed_packet_count > 0) { + /* + * A stream without a packet context, and thus without + * content and packet size members, can't have more than + * one packet. + */ + ret = -1; + goto end; + } + empty_packet = (stream->events->len == 0); ret = bt_ctf_field_validate(stream->packet_header); if (ret) {