From cdaec3808e756fee3c4e17d0168ec6429eff0dbc Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 7 May 2014 09:53:53 +0200 Subject: tests: Don't call visit_end_struct() after visit_start_struct() fails When visit_start_struct() fails, visit_end_struct() must not be called. Three out of four visit_type_TestStruct() call it anyway. As far as I can tell, visit_start_struct() doesn't actually fail there. Fix them anyway. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Signed-off-by: Luiz Capitulino --- tests/test-qmp-input-strict.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'tests/test-qmp-input-strict.c') diff --git a/tests/test-qmp-input-strict.c b/tests/test-qmp-input-strict.c index 449d285..ec798c2 100644 --- a/tests/test-qmp-input-strict.c +++ b/tests/test-qmp-input-strict.c @@ -72,14 +72,22 @@ typedef struct TestStruct static void visit_type_TestStruct(Visitor *v, TestStruct **obj, const char *name, Error **errp) { + Error *err = NULL; + visit_start_struct(v, (void **)obj, "TestStruct", name, sizeof(TestStruct), - errp); + &err); + if (err) { + goto out; + } + + visit_type_int(v, &(*obj)->integer, "integer", &err); + visit_type_bool(v, &(*obj)->boolean, "boolean", &err); + visit_type_str(v, &(*obj)->string, "string", &err); - visit_type_int(v, &(*obj)->integer, "integer", errp); - visit_type_bool(v, &(*obj)->boolean, "boolean", errp); - visit_type_str(v, &(*obj)->string, "string", errp); + visit_end_struct(v, &err); - visit_end_struct(v, errp); +out: + error_propagate(errp, err); } static void test_validate_struct(TestInputVisitorData *data, -- cgit v1.1