Found by Coverity:
3. returned_null: bt_ctf_field_string_get_value returns null (checked 10
out of 12 times).
CID
1376192 (#1 of 1): Dereference null return value (NULL_RETURNS)
4. dereference: Dereferencing a pointer that might be null
bt_ctf_field_string_get_value(field) when calling print_escape_string.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
case CTF_TYPE_ENUM:
return print_enum(pretty, field);
case CTF_TYPE_STRING:
case CTF_TYPE_ENUM:
return print_enum(pretty, field);
case CTF_TYPE_STRING:
+ {
+ const char *str;
+
+ str = bt_ctf_field_string_get_value(field);
+ if (!str) {
+ return BT_COMPONENT_STATUS_ERROR;
+ }
+
if (pretty->use_colors) {
g_string_append(pretty->string, COLOR_STRING_VALUE);
}
if (pretty->use_colors) {
g_string_append(pretty->string, COLOR_STRING_VALUE);
}
- print_escape_string(pretty, bt_ctf_field_string_get_value(field));
+ print_escape_string(pretty, str);
if (pretty->use_colors) {
g_string_append(pretty->string, COLOR_RST);
}
return BT_COMPONENT_STATUS_OK;
if (pretty->use_colors) {
g_string_append(pretty->string, COLOR_RST);
}
return BT_COMPONENT_STATUS_OK;
case CTF_TYPE_STRUCT:
return print_struct(pretty, field, print_names, filter_fields,
filter_array_len);
case CTF_TYPE_STRUCT:
return print_struct(pretty, field, print_names, filter_fields,
filter_array_len);