From patchwork Mon Feb 17 11:52:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcel Apfelbaum X-Patchwork-Id: 320942 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 314A12C00BB for ; Mon, 17 Feb 2014 22:53:24 +1100 (EST) Received: from localhost ([::1]:39267 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFMlF-0008HZ-QN for incoming@patchwork.ozlabs.org; Mon, 17 Feb 2014 06:53:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57536) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFMkn-00089v-TN for qemu-devel@nongnu.org; Mon, 17 Feb 2014 06:52:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WFMkh-0007G0-Uh for qemu-devel@nongnu.org; Mon, 17 Feb 2014 06:52:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:9741) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFMkh-0007Fs-Lk for qemu-devel@nongnu.org; Mon, 17 Feb 2014 06:52:47 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1HBqi76011643 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 17 Feb 2014 06:52:44 -0500 Received: from localhost.localdomain.com (vpn-202-54.tlv.redhat.com [10.35.202.54]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s1HBqfLX013039; Mon, 17 Feb 2014 06:52:41 -0500 From: Marcel Apfelbaum To: qemu-devel@nongnu.org Date: Mon, 17 Feb 2014 13:52:52 +0200 Message-Id: <1392637972-24719-1-git-send-email-marcel.a@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: pbonzini@redhat.com, mdroth@linux.vnet.ibm.com, lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH] qapi: output visitor crashes qemu if it encounters a NULL value X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org A NULL value is not added to visitor's stack, but there is no check for that when the visitor tries to return that value, leading to Qemu crash. Signed-off-by: Marcel Apfelbaum Reviewed-by: Eric Blake --- qapi/qmp-output-visitor.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c index 74a5684..0562f49 100644 --- a/qapi/qmp-output-visitor.c +++ b/qapi/qmp-output-visitor.c @@ -66,6 +66,11 @@ static QObject *qmp_output_pop(QmpOutputVisitor *qov) static QObject *qmp_output_first(QmpOutputVisitor *qov) { QStackEntry *e = QTAILQ_LAST(&qov->stack, QStack); + + if (!e) { + return NULL; + } + return e->value; }