qapi: Fix object input visit beyond end of list

Backports commit 1f41a645b65530859bf5984aa08e103bb452b473 from qemu
This commit is contained in:
Markus Armbruster 2018-03-02 12:22:44 -05:00 committed by Lioncash
parent ac1a61af47
commit 67cb4b0900
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -121,10 +121,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++;
}
}