qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/8] qapi: fix NULL pointer dereference


From: Paolo Bonzini
Subject: [Qemu-devel] [PATCH 1/8] qapi: fix NULL pointer dereference
Date: Fri, 16 Dec 2011 13:01:51 +0100

QAPI currently cannot deal with no object pushed to the stack,
and dereferences a NULL pointer.  This is visible with

    qom-get path=/i440fx/piix3 property=romfile

after static non-string properties are introduced.

Signed-off-by: Paolo Bonzini <address@hidden>
---
 qapi/qmp-output-visitor.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c
index f76d015..29575da 100644
--- a/qapi/qmp-output-visitor.c
+++ b/qapi/qmp-output-visitor.c
@@ -65,13 +65,13 @@ static QObject *qmp_output_pop(QmpOutputVisitor *qov)
 static QObject *qmp_output_first(QmpOutputVisitor *qov)
 {
     QStackEntry *e = QTAILQ_LAST(&qov->stack, QStack);
-    return e->value;
+    return e ? e->value : NULL;
 }
 
 static QObject *qmp_output_last(QmpOutputVisitor *qov)
 {
     QStackEntry *e = QTAILQ_FIRST(&qov->stack);
-    return e->value;
+    return e ? e->value : NULL;
 }
 
 static void qmp_output_add_obj(QmpOutputVisitor *qov, const char *name,
-- 
1.7.7.1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]