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 22:03:07 +0000 (18:03 -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/writer/event-types.c
tests/lib/test_ctf_writer.c

index 7f7fa7622247abb3e09288960429722d3f9cf8a1..08b832e8255df995e3ca3ac2dc2cc53b24055240 100644 (file)
@@ -550,6 +550,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 0927a325cc0a06ab7b071b554d760ff5a4e8aa2b..28ffae51f195a1b691f5524660a89dbd66cd847c 100644 (file)
@@ -621,7 +621,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.026164 seconds and 4 git commands to generate.