Fix: event_header is optional
[babeltrace.git] / lib / ctf-ir / stream.c
index 3d21ecac7ea4b1fbf709a153c09e0f0d05b802de..cc4d9795064951b529fefe8b89c87c9c6fe4206c 100644 (file)
@@ -1126,6 +1126,10 @@ static int auto_populate_event_header(struct bt_ctf_stream *stream,
 
        assert(event);
 
+       if (!event->event_header) {
+               goto end;
+       }
+
        if (event->frozen) {
                BT_LOGW_STR("Cannot populate event header field: event is frozen.");
                ret = -1;
@@ -1569,13 +1573,15 @@ int bt_ctf_stream_flush(struct bt_ctf_stream *stream)
                        stream->pos.offset, stream->pos.packet_size);
 
                /* Write event header */
-               BT_LOGV_STR("Serializing event's header field.");
-               ret = bt_ctf_field_serialize(event->event_header,
-                       &stream->pos, native_byte_order);
-               if (ret) {
-                       BT_LOGW("Cannot serialize event's header field: "
-                               "field-addr=%p", event->event_header);
-                       goto end;
+               if (event->event_header) {
+                       BT_LOGV_STR("Serializing event's header field.");
+                       ret = bt_ctf_field_serialize(event->event_header,
+                                       &stream->pos, native_byte_order);
+                       if (ret) {
+                               BT_LOGW("Cannot serialize event's header field: "
+                                               "field-addr=%p", event->event_header);
+                               goto end;
+                       }
                }
 
                /* Write stream event context */
This page took 0.024145 seconds and 4 git commands to generate.