Handle empty strings in the notif-iter btr_string callbacks
[babeltrace.git] / plugins / ctf / common / notif-iter / notif-iter.c
index f29b72eeee7f5ad87e968549f131b1705be70990..5e06362613c1e6f5500322ef4ecb5026291afc0d 100644 (file)
@@ -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);
 
This page took 0.023664 seconds and 4 git commands to generate.