From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37500) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ci6bi-0004UG-75 for qemu-devel@nongnu.org; Sun, 26 Feb 2017 16:43:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ci6bf-0004OC-B0 for qemu-devel@nongnu.org; Sun, 26 Feb 2017 16:43:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47712) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ci6bf-0004NW-50 for qemu-devel@nongnu.org; Sun, 26 Feb 2017 16:43:51 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4693780F6D for ; Sun, 26 Feb 2017 21:43:51 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1QLhnYH027463 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Sun, 26 Feb 2017 16:43:51 -0500 From: Markus Armbruster Date: Sun, 26 Feb 2017 22:43:43 +0100 Message-Id: <1488145424-14974-26-git-send-email-armbru@redhat.com> In-Reply-To: <1488145424-14974-1-git-send-email-armbru@redhat.com> References: <1488145424-14974-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH v2 25/26] qapi: Fix object input visit beyond end of list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Signed-off-by: Markus Armbruster --- qapi/qobject-input-visitor.c | 11 ++++++++--- tests/test-qobject-input-visitor.c | 2 -- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c index 47e546e..6bb5a80 100644 --- a/qapi/qobject-input-visitor.c +++ b/qapi/qobject-input-visitor.c @@ -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++; } } diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-visitor.c index 4b82707..8943cab 100644 --- a/tests/test-qobject-input-visitor.c +++ b/tests/test-qobject-input-visitor.c @@ -952,10 +952,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); } -- 2.7.4