Fix: unchecked return value of bt_ctf_field_type_get_field_at_index
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 3 Aug 2017 14:03:32 +0000 (10:03 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 9 Aug 2017 21:41:49 +0000 (17:41 -0400)
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 <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
lib/ctf-ir/field-types.c

index 485c5e8f3ea71e2f68d6b84f62559af01c5a57e2..06d8c76717571d136e5d9e3a9d529125e6d5b830 100644 (file)
@@ -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(
This page took 0.026245 seconds and 4 git commands to generate.