From e5df2ae3cdc84781bb59b3d3791b972942ce7880 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Tue, 15 Nov 2016 12:31:30 -0500 Subject: [PATCH] Handle empty strings in the notif-iter btr_string callbacks MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- plugins/ctf/common/notif-iter/notif-iter.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugins/ctf/common/notif-iter/notif-iter.c b/plugins/ctf/common/notif-iter/notif-iter.c index f29b72ee..5e063626 100644 --- a/plugins/ctf/common/notif-iter/notif-iter.c +++ b/plugins/ctf/common/notif-iter/notif-iter.c @@ -1370,6 +1370,18 @@ enum bt_ctf_btr_status btr_string_begin_cb( goto end; } + /* + * Initialize string field payload to an empty string since in the + * case of a length 0 string the btr_string_cb won't be called and + * we will end up with an unset string payload. + */ + ret = bt_ctf_field_string_set_value(field, ""); + if (ret) { + PERR("Failed to initialize string field\n"); + status = BT_CTF_BTR_STATUS_ERROR; + goto end; + } + end: BT_PUT(field); -- 2.34.1