From 35628ac71c433580daba71470a5d877f46c5c652 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Tue, 29 Jul 2014 16:55:36 -0400 Subject: [PATCH] Fix: bt_ctf_field_type_structure_add_field argument validation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- formats/ctf/writer/event-types.c | 1 + tests/lib/test_ctf_writer.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/formats/ctf/writer/event-types.c b/formats/ctf/writer/event-types.c index 7f7fa762..08b832e8 100644 --- a/formats/ctf/writer/event-types.c +++ b/formats/ctf/writer/event-types.c @@ -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; } diff --git a/tests/lib/test_ctf_writer.c b/tests/lib/test_ctf_writer.c index 0927a325..28ffae51 100644 --- a/tests/lib/test_ctf_writer.c +++ b/tests/lib/test_ctf_writer.c @@ -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, -- 2.34.1