From 1d10b44546e2605b6dd8a006dcc0d03166649e2d Mon Sep 17 00:00:00 2001 From: Marcel Apfelbaum Date: Mon, 26 May 2014 15:40:55 +0300 Subject: [PATCH] qapi: Avoid output visitor crashing if it encounters a NULL value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Reviewed-by: Eric Blake Acked-by: Luiz Capitulino Signed-off-by: Marcel Apfelbaum Acked-by: Michael S. Tsirkin Acked-by: Michael Roth Signed-off-by: Andreas Färber --- qapi/qmp-output-visitor.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c index 74a5684ed3..96b338463e 100644 --- a/qapi/qmp-output-visitor.c +++ b/qapi/qmp-output-visitor.c @@ -66,6 +66,12 @@ static QObject *qmp_output_pop(QmpOutputVisitor *qov) static QObject *qmp_output_first(QmpOutputVisitor *qov) { QStackEntry *e = QTAILQ_LAST(&qov->stack, QStack); + + /* FIXME - find a better way to deal with NULL values */ + if (!e) { + return NULL; + } + return e->value; }