From 664f50c80ff21a798a2c9dfd9c601529a63dda26 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 27 Jan 2017 00:41:39 -0500 Subject: [PATCH] Writer: don't allow more than one packet without packet context MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- formats/ctf/ir/stream.c | 10 ++++++++++ 1 file changed, 10 insertions(+) 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) { -- 2.34.1