From: Jérémie Galarneau Date: Tue, 15 Nov 2016 17:31:30 +0000 (-0500) Subject: Handle empty strings in the notif-iter btr_string callbacks X-Git-Tag: v2.0.0-pre1~714 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=e5df2ae3cdc84781bb59b3d3791b972942ce7880 Handle empty strings in the notif-iter btr_string callbacks Signed-off-by: Jérémie Galarneau --- 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);