Fix: Check validity of returned ctf_type_id
[babeltrace.git] / formats / ctf / ir / visitor.c
index 6fc6e30ed679359df9f1527ca10f24dfc56c687f..9082138d6669151eb549a25fbefc8ac25ee715c6 100644 (file)
@@ -722,10 +722,16 @@ void print_path(const char *field_name,
                struct bt_ctf_field_path *field_path)
 {
        int i;
+       enum ctf_type_id type_id = bt_ctf_field_type_get_type_id(
+               resolved_type);
+
+       if (type_id < CTF_TYPE_UNKNOWN || type_id >= NR_CTF_TYPES) {
+               type_id = CTF_TYPE_UNKNOWN;
+       }
 
        printf_verbose("Resolved field \"%s\" as type \"%s\", ",
                field_name,
-               type_names[bt_ctf_field_type_get_type_id(resolved_type)]);
+               type_names[type_id]);
        printf_verbose("path: %s",
                absolute_path_prefixes[field_path->root]);
 
This page took 0.025051 seconds and 4 git commands to generate.