From nobody Tue Feb 10 00:38:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493911993182881.9913669889725; Thu, 4 May 2017 08:33:13 -0700 (PDT) Received: from localhost ([::1]:42569 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6Ikf-0003Ii-O6 for importer@patchew.org; Thu, 04 May 2017 11:33:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56416) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6Ic3-00026f-La for qemu-devel@nongnu.org; Thu, 04 May 2017 11:24:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6Ic0-0008Kx-IT for qemu-devel@nongnu.org; Thu, 04 May 2017 11:24:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41756) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6Ic0-0008Iz-8Y for qemu-devel@nongnu.org; Thu, 04 May 2017 11:24:12 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 45E7561E78 for ; Thu, 4 May 2017 15:24:11 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-149.ams2.redhat.com [10.36.116.149]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0F6B97EDBB for ; Thu, 4 May 2017 15:24:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 481DD11385EC; Thu, 4 May 2017 17:24:06 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 45E7561E78 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=armbru@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 45E7561E78 From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 4 May 2017 17:24:00 +0200 Message-Id: <1493911445-19568-24-git-send-email-armbru@redhat.com> In-Reply-To: <1493911445-19568-1-git-send-email-armbru@redhat.com> References: <1493911445-19568-1-git-send-email-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 04 May 2017 15:24:11 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 23/28] qobject-input-visitor: Catch misuse of end_struct vs. end_list X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Message-Id: <1493282486-28338-5-git-send-email-armbru@redhat.com> Reviewed-by: Marc-Andr=C3=A9 Lureau [More elaborate assertions for clarity] --- qapi/qobject-input-visitor.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c index 2530959..d0f0002 100644 --- a/qapi/qobject-input-visitor.c +++ b/qapi/qobject-input-visitor.c @@ -291,6 +291,15 @@ static void qobject_input_start_struct(Visitor *v, con= st char *name, void **obj, } } =20 +static void qobject_input_end_struct(Visitor *v, void **obj) +{ + QObjectInputVisitor *qiv =3D to_qiv(v); + StackObject *tos =3D QSLIST_FIRST(&qiv->stack); + + assert(qobject_type(tos->obj) =3D=3D QTYPE_QDICT && tos->h); + qobject_input_pop(v, obj); +} + =20 static void qobject_input_start_list(Visitor *v, const char *name, GenericList **list, size_t size, @@ -346,6 +355,14 @@ static void qobject_input_check_list(Visitor *v, Error= **errp) } } =20 +static void qobject_input_end_list(Visitor *v, void **obj) +{ + QObjectInputVisitor *qiv =3D to_qiv(v); + StackObject *tos =3D QSLIST_FIRST(&qiv->stack); + + assert(qobject_type(tos->obj) =3D=3D QTYPE_QLIST && !tos->h); + qobject_input_pop(v, obj); +} =20 static void qobject_input_start_alternate(Visitor *v, const char *name, GenericAlternate **obj, size_t s= ize, @@ -645,11 +662,11 @@ static QObjectInputVisitor *qobject_input_visitor_bas= e_new(QObject *obj) v->visitor.type =3D VISITOR_INPUT; v->visitor.start_struct =3D qobject_input_start_struct; v->visitor.check_struct =3D qobject_input_check_struct; - v->visitor.end_struct =3D qobject_input_pop; + v->visitor.end_struct =3D qobject_input_end_struct; v->visitor.start_list =3D qobject_input_start_list; v->visitor.next_list =3D qobject_input_next_list; v->visitor.check_list =3D qobject_input_check_list; - v->visitor.end_list =3D qobject_input_pop; + v->visitor.end_list =3D qobject_input_end_list; v->visitor.start_alternate =3D qobject_input_start_alternate; v->visitor.optional =3D qobject_input_optional; v->visitor.free =3D qobject_input_free; --=20 2.7.4