Writer: don't allow more than one packet without packet context
[babeltrace.git] / formats / ctf / ir / stream.c
index 979d40e92839fd94f066bad1d8d226e5153e170b..e6e7575a7102c63415c75241cca3e102ed93e1af 100644 (file)
@@ -884,6 +884,16 @@ int bt_ctf_stream_flush(struct bt_ctf_stream *stream)
                goto end;
        }
 
                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) {
        empty_packet = (stream->events->len == 0);
        ret = bt_ctf_field_validate(stream->packet_header);
        if (ret) {
This page took 0.023789 seconds and 4 git commands to generate.