From aa15981cec13ee886e86b7d3755b9654cebafc0c Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 3 Aug 2017 10:03:32 -0400 Subject: [PATCH] Fix: unchecked return value of bt_ctf_field_type_get_field_at_index MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- lib/ctf-ir/field-types.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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( -- 2.34.1