summaryrefslogtreecommitdiff
path: root/qapi
diff options
context:
space:
mode:
authorMarcel Apfelbaum <marcel.a@redhat.com>2014-05-26 15:40:55 +0300
committerAndreas Färber <afaerber@suse.de>2014-05-28 17:36:04 +0200
commit1d10b44546e2605b6dd8a006dcc0d03166649e2d (patch)
treed3cfba7c68eb2c04b34c36dea6b595b571b9d471 /qapi
parent13d7adf92a97c8252df6165ec84127798f3096d3 (diff)
downloadqemu-1d10b44546e2605b6dd8a006dcc0d03166649e2d.zip
qapi: Avoid output visitor crashing if it encounters a NULL value
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 <eblake@redhat.com> Acked-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'qapi')
-rw-r--r--qapi/qmp-output-visitor.c6
1 files changed, 6 insertions, 0 deletions
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;
}