From ff9a2f93b481bd5ca0d32ef48ab34e027ea9ceb6 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Sat, 16 Sep 2017 00:58:25 -0400 Subject: [PATCH] Fix: ctf: notif-iter: accept EOF at beginning of packet context with no PH MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- plugins/ctf/common/notif-iter/notif-iter.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plugins/ctf/common/notif-iter/notif-iter.c b/plugins/ctf/common/notif-iter/notif-iter.c index 8bb79db8..25d6c94a 100644 --- a/plugins/ctf/common/notif-iter/notif-iter.c +++ b/plugins/ctf/common/notif-iter/notif-iter.c @@ -489,6 +489,8 @@ enum bt_ctf_notif_iter_status request_medium_bytes( BT_LOGV_MEM(buffer_addr, buffer_sz, "Returned bytes at %p:", buffer_addr); } else if (m_status == BT_CTF_NOTIF_ITER_MEDIUM_STATUS_EOF) { + struct bt_ctf_field_type *ph_ft = + bt_ctf_trace_get_packet_header_type(notit->meta.trace); struct bt_ctf_field_type *eh_ft = NULL; struct bt_ctf_field_type *sec_ft = NULL; struct bt_ctf_field_type *ec_ft = NULL; @@ -507,6 +509,16 @@ enum bt_ctf_notif_iter_status request_medium_bytes( goto bad_state; } + if (notit->state == STATE_DSCOPE_STREAM_PACKET_CONTEXT_BEGIN) { + /* + * Beginning of packet context context is only + * valid if there's no packet header. + */ + if (!ph_ft) { + goto good_state; + } + } + eh_ft = bt_ctf_stream_class_get_event_header_type( notit->meta.stream_class); sec_ft = bt_ctf_stream_class_get_event_context_type( @@ -580,6 +592,7 @@ bad_state: m_status = BT_CTF_NOTIF_ITER_MEDIUM_STATUS_ERROR; good_state: + bt_put(ph_ft); bt_put(eh_ft); bt_put(sec_ft); bt_put(ec_ft); -- 2.34.1