Received: from eggs.gnu.org ([2001:4830:134:3::10]:59111) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bL51w-0006Y7-Cu for qemu-devel@nongnu.org; Thu, 07 Jul 2016 04:51:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bL51r-0004nh-BL for qemu-devel@nongnu.org; Thu, 07 Jul 2016 04:51:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50360) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bL51r-0004nF-5F for qemu-devel@nongnu.org; Thu, 07 Jul 2016 04:51:27 -0400 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 15B8E10E7BC for ; Thu, 7 Jul 2016 08:51:26 +0000 (UTC) From: Markus Armbruster References: <1467809017-25023-1-git-send-email-pbonzini@redhat.com> <1467809017-25023-2-git-send-email-pbonzini@redhat.com> <577D2629.80007@redhat.com> Date: Thu, 07 Jul 2016 10:19:54 +0200 In-Reply-To: <577D2629.80007@redhat.com> (Eric Blake's message of "Wed, 6 Jul 2016 09:39:21 -0600") Message-ID: <87inwhsvv9.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH] qapi: change QmpInputVisitor to QSLIST List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Paolo Bonzini , qemu-devel@nongnu.org Eric Blake writes: > On 07/06/2016 06:43 AM, Paolo Bonzini wrote: >> This saves a lot of memory compared to a statically-sized array. >> >> Signed-off-by: Paolo Bonzini >> --- >> qapi/qmp-input-visitor.c | 53 ++++++++++++++++++++++++------------------------ >> 1 file changed, 26 insertions(+), 27 deletions(-) >> > >> @@ -99,17 +100,10 @@ static const QListEntry *qmp_input_push(QmpInputVisitor *qiv, QObject *obj, >> Error **errp) >> { >> GHashTable *h; >> - StackObject *tos = &qiv->stack[qiv->nb_stack]; >> + StackObject *tos = g_new0(StackObject, 1); >> >> assert(obj); >> - if (qiv->nb_stack >= QIV_STACK_SIZE) { > > You should also delete QIV_STACK_SIZE as it is now unused. Actually, you should either prove that untrusted input still cannot make us allocated unbounded amounts of memory, or bring the limit right back. >> @@ -127,9 +121,7 @@ static const QListEntry *qmp_input_push(QmpInputVisitor *qiv, QObject *obj, >> static void qmp_input_check_struct(Visitor *v, Error **errp) >> { >> QmpInputVisitor *qiv = to_qiv(v); >> - StackObject *tos = &qiv->stack[qiv->nb_stack - 1]; >> - >> - assert(qiv->nb_stack > 0); >> + StackObject *tos = QSLIST_FIRST(&qiv->stack); > > Does QSLIST_FIRST() properly crash if the list is empty, or do we need It returns null. > to add an assert(tos) to replace the assertion on nb_stack being non-zero? We do need to. > Otherwise looking reasonable; looking forward to v2.