Fix: bt_ctf_field_type_structure_add_field argument validation
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 29 Jul 2014 20:55:36 +0000 (16:55 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 29 Jul 2014 21:26:30 +0000 (17:26 -0400)
bt_ctf_field_type_structure_add_field is not setting the return
value to a negative value if the parameter validation fails. The
function would abort while appearing to have succeeded.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
formats/ctf/ir/event-types.c
tests/lib/test_ctf_writer.c

index 48a2a746ad3c252fe952c746fa88dbd724c45d9a..7d01ce8b6535f1b7fa87d28329159b0242d2d1b0 100644 (file)
@@ -1016,6 +1016,7 @@ int bt_ctf_field_type_structure_add_field(struct bt_ctf_field_type *type,
                validate_identifier(field_name) ||
                (type->declaration->id != CTF_TYPE_STRUCT) ||
                bt_ctf_field_type_validate(field_type)) {
+               ret = -1;
                goto end;
        }
 
index 7720719e9074a6c86d54480e35edcb3af6df0d58..bbe354f2fe0ce938a9638b9f2151450ede48540c 100644 (file)
@@ -1219,7 +1219,7 @@ void type_field_tests()
        ok(!enumeration_array_type,
                "Check enumeration types are validated when creating an array");
        ok(bt_ctf_field_type_structure_add_field(composite_structure_type,
-               enumeration_type, "enumeration") == 0,
+               enumeration_type, "enumeration"),
                "Check enumeration types are validated when adding them as structure members");
        enumeration = bt_ctf_field_create(enumeration_type);
        ok(!enumeration,
This page took 0.028057 seconds and 4 git commands to generate.