From: Mathieu Desnoyers Date: Thu, 3 Aug 2017 14:03:32 +0000 (-0400) Subject: Fix: unchecked return value of bt_ctf_field_type_get_field_at_index X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=aa15981cec13ee886e86b7d3755b9654cebafc0c Fix: unchecked return value of bt_ctf_field_type_get_field_at_index CID 1376152 (#1 of 1): Unchecked return value (CHECKED_RETURN). check_return: Calling bt_ctf_field_type_structure_get_field_by_index without checking return value (as is done elsewhere 23 out of 25 times). Signed-off-by: Mathieu Desnoyers Signed-off-by: Jérémie Galarneau --- diff --git a/lib/ctf-ir/field-types.c b/lib/ctf-ir/field-types.c index 485c5e8f..06d8c767 100644 --- a/lib/ctf-ir/field-types.c +++ b/lib/ctf-ir/field-types.c @@ -5284,9 +5284,15 @@ struct bt_ctf_field_type *bt_ctf_field_type_get_field_at_index( switch (type_id) { case CTF_TYPE_STRUCT: - bt_ctf_field_type_structure_get_field_by_index(field_type, - NULL, &field, index); + { + int ret = bt_ctf_field_type_structure_get_field_by_index( + field_type, NULL, &field, index); + if (ret) { + field = NULL; + goto end; + } break; + } case CTF_TYPE_VARIANT: { int ret = bt_ctf_field_type_variant_get_field_by_index(