From nobody Sat Feb 7 06:20:34 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 1494318718822966.2441428487596; Tue, 9 May 2017 01:31:58 -0700 (PDT) Received: from localhost ([::1]:35763 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d80Yn-0005tF-2x for importer@patchew.org; Tue, 09 May 2017 04:31:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44115) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d80Ab-00085T-3T for qemu-devel@nongnu.org; Tue, 09 May 2017 04:07:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d80AV-0007ZM-K5 for qemu-devel@nongnu.org; Tue, 09 May 2017 04:06:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55758) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d80AV-0007Y1-Br for qemu-devel@nongnu.org; Tue, 09 May 2017 04:06:51 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 68B5B81240 for ; Tue, 9 May 2017 08:06:50 +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 34B255C7A8 for ; Tue, 9 May 2017 08:06:50 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 832CB110CFE5; Tue, 9 May 2017 10:06:45 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 68B5B81240 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=armbru@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 68B5B81240 From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 9 May 2017 10:06:40 +0200 Message-Id: <1494317205-2211-24-git-send-email-armbru@redhat.com> In-Reply-To: <1494317205-2211-1-git-send-email-armbru@redhat.com> References: <1494317205-2211-1-git-send-email-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 09 May 2017 08:06:50 +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 v3 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