浏览代码

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>
Marcel Apfelbaum 11 年之前
父节点
当前提交
1d10b44546
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      qapi/qmp-output-visitor.c

+ 6 - 0
qapi/qmp-output-visitor.c

@@ -66,6 +66,12 @@ static QObject *qmp_output_pop(QmpOutputVisitor *qov)
 static QObject *qmp_output_first(QmpOutputVisitor *qov)
 static QObject *qmp_output_first(QmpOutputVisitor *qov)
 {
 {
     QStackEntry *e = QTAILQ_LAST(&qov->stack, QStack);
     QStackEntry *e = QTAILQ_LAST(&qov->stack, QStack);
+
+    /* FIXME - find a better way to deal with NULL values */
+    if (!e) {
+        return NULL;
+    }
+
     return e->value;
     return e->value;
 }
 }