qapi: Fix object input visit beyond end of list

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1488544368-30622-28-git-send-email-armbru@redhat.com>
This commit is contained in:
Markus Armbruster 2017-03-03 13:32:47 +01:00
parent a9416dc62c
commit 1f41a645b6
2 changed files with 8 additions and 5 deletions

View File

@ -122,10 +122,15 @@ static QObject *qobject_input_try_get_object(QObjectInputVisitor *qiv,
} else {
assert(qobject_type(qobj) == QTYPE_QLIST);
assert(!name);
ret = qlist_entry_obj(tos->entry);
assert(ret);
if (tos->entry) {
ret = qlist_entry_obj(tos->entry);
if (consume) {
tos->entry = qlist_next(tos->entry);
}
} else {
ret = NULL;
}
if (consume) {
tos->entry = qlist_next(tos->entry);
tos->index++;
}
}

View File

@ -953,10 +953,8 @@ static void test_visitor_in_fail_list(TestInputVisitorData *data,
v = visitor_input_test_init(data, "[]");
visit_start_list(v, NULL, NULL, 0, &error_abort);
#if 0 /* FIXME crash */
visit_type_int(v, NULL, &i64, &err);
error_free_or_abort(&err);
#endif
visit_end_list(v, NULL);
}