From: Jérémie Galarneau Date: Tue, 29 Jul 2014 20:55:36 +0000 (-0400) Subject: Fix: bt_ctf_field_type_structure_add_field argument validation X-Git-Tag: v2.0.0-pre1~1511 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=e6235f1fd983de6cd80951f0ed179894839d6ac9 Fix: bt_ctf_field_type_structure_add_field argument validation 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 --- diff --git a/formats/ctf/ir/event-types.c b/formats/ctf/ir/event-types.c index 48a2a746..7d01ce8b 100644 --- a/formats/ctf/ir/event-types.c +++ b/formats/ctf/ir/event-types.c @@ -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; } diff --git a/tests/lib/test_ctf_writer.c b/tests/lib/test_ctf_writer.c index 7720719e..bbe354f2 100644 --- a/tests/lib/test_ctf_writer.c +++ b/tests/lib/test_ctf_writer.c @@ -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,