Writer fix: set packet size to 0 on flush failure
[babeltrace.git] / formats / ctf / ir / stream.c
index 845153c13399a190b35dd17392c7af840ae180b6..96da8af3ce43aa7b3a68feb34aded7c4c3e8f275 100644 (file)
@@ -1059,6 +1059,16 @@ end:
                                "content_size");
        }
        bt_put(integer);
                                "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;
 }
 
        return ret;
 }
 
This page took 0.022636 seconds and 4 git commands to generate.