Fix: check return value of get_char_array
[babeltrace.git] / formats / ctf / events.c
index 890956e9f919884441ec6e7c5b80dd4b4a5d3355..efcd6f05fafb62e4a7b63856308315a352e534bd 100644 (file)
@@ -515,12 +515,18 @@ int64_t bt_ctf_get_int64(const struct definition *field)
 char *bt_ctf_get_char_array(const struct definition *field)
 {
        char *ret = NULL;
+       GString *char_array;
 
-       if (field && bt_ctf_field_type(field) == CTF_TYPE_ARRAY)
-               ret = get_char_array(field)->str;
-       else
-               bt_ctf_field_set_error(-EINVAL);
+       if (field && bt_ctf_field_type(field) == CTF_TYPE_ARRAY) {
+               char_array = get_char_array(field);
+               if (char_array) {
+                       ret = char_array->str;
+                       goto end;
+               }
+       }
+       bt_ctf_field_set_error(-EINVAL);
 
+end:
        return ret;
 }
 
This page took 0.02345 seconds and 4 git commands to generate.