From: Jérémie Galarneau Date: Wed, 13 May 2015 15:50:05 +0000 (-0400) Subject: Fix: Check validity of returned ctf_type_id X-Git-Tag: v2.0.0-pre1~1237 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=9cb5c24b0023a769be1f6d9b6ca5d70792a11e22 Fix: Check validity of returned ctf_type_id Reported by Coverity Scan as ** CID 1297897: Error handling issues (CHECKED_RETURN) /formats/ctf/ir/visitor.c: 726 in print_path() Signed-off-by: Jérémie Galarneau --- diff --git a/formats/ctf/ir/visitor.c b/formats/ctf/ir/visitor.c index 6fc6e30e..9082138d 100644 --- a/formats/ctf/ir/visitor.c +++ b/formats/ctf/ir/visitor.c @@ -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]);