aboutsummaryrefslogtreecommitdiff
path: root/tests/test-string-input-visitor.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2017-03-03 13:32:46 +0100
committerMarkus Armbruster <armbru@redhat.com>2017-03-05 09:14:20 +0100
commita9416dc62c36079b93b4951c894a0b15e53bb38c (patch)
tree3c5af2b9ea8f6ec2a98b014a3a075d4c0ad47c6a /tests/test-string-input-visitor.c
parenta4a1c70dc759e5b81627e96564f344ab43ea86eb (diff)
tests: Cover input visit beyond end of list
When you try to visit beyond the end of a list, the qobject input visitor crashes, and the string visitor screws returns garbage. The generated list visits never go beyond the list end, but manual visits could. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <1488544368-30622-27-git-send-email-armbru@redhat.com>
Diffstat (limited to 'tests/test-string-input-visitor.c')
-rw-r--r--tests/test-string-input-visitor.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test-string-input-visitor.c b/tests/test-string-input-visitor.c
index fbe380acbe..6db850bc89 100644
--- a/tests/test-string-input-visitor.c
+++ b/tests/test-string-input-visitor.c
@@ -123,6 +123,7 @@ static void test_visitor_in_intList(TestInputVisitorData *data,
int64List *res = NULL;
int64List *tail;
Visitor *v;
+ int64_t val;
/* Valid lists */
@@ -175,6 +176,21 @@ static void test_visitor_in_intList(TestInputVisitorData *data,
visit_end_list(v, (void **)&res);
qapi_free_int64List(res);
+
+ /* Visit beyond end of list */
+ v = visitor_input_test_init(data, "0");
+
+ visit_start_list(v, NULL, (GenericList **)&res, sizeof(*res),
+ &error_abort);
+ tail = res;
+ visit_type_int64(v, NULL, &tail->value, &err);
+ g_assert_cmpint(tail->value, ==, 0);
+ visit_type_int64(v, NULL, &val, &err);
+ g_assert_cmpint(val, ==, 1); /* BUG */
+ visit_check_list(v, &error_abort);
+ visit_end_list(v, (void **)&res);
+
+ qapi_free_int64List(res);
}
static void test_visitor_in_bool(TestInputVisitorData *data,