From mboxrd@z Thu Jan 1 00:00:00 1970 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 From: Marcel Apfelbaum Date: Mon, 17 Feb 2014 13:52:52 +0200 Message-Id: <1392637972-24719-1-git-send-email-marcel.a@redhat.com> Subject: [Qemu-devel] [PATCH] qapi: output visitor crashes qemu if it encounters a NULL value List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, mdroth@linux.vnet.ibm.com, lcapitulino@redhat.com 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 --- 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; } -- 1.8.3.1