From: Jérémie Galarneau Date: Fri, 3 Feb 2017 02:21:26 +0000 (-0500) Subject: Writer fix: set packet size to 0 on flush failure X-Git-Tag: v2.0.0-pre1~514 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=cd7d8fb7b8a599187c9d0e479969c86cf5640397 Writer fix: set packet size to 0 on flush failure Signed-off-by: Jérémie Galarneau --- diff --git a/formats/ctf/ir/stream.c b/formats/ctf/ir/stream.c index 845153c1..96da8af3 100644 --- a/formats/ctf/ir/stream.c +++ b/formats/ctf/ir/stream.c @@ -1059,6 +1059,16 @@ end: "content_size"); } bt_put(integer); + + if (ret < 0) { + /* + * We failed to write the packet. Its size is therefore set to 0 + * to ensure the next mapping is done in the same place rather + * than advancing by "stream->pos.packet_size", which would + * leave a corrupted packet in the trace. + */ + stream->pos.packet_size = 0; + } return ret; }