From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:60606) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbWUN-0007MP-JK for qemu-devel@nongnu.org; Fri, 16 Dec 2011 07:02:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RbWUG-0006u1-7c for qemu-devel@nongnu.org; Fri, 16 Dec 2011 07:02:11 -0500 Received: from mail-ee0-f45.google.com ([74.125.83.45]:45954) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbWUG-0006tv-10 for qemu-devel@nongnu.org; Fri, 16 Dec 2011 07:02:04 -0500 Received: by eekb45 with SMTP id b45so3474531eek.4 for ; Fri, 16 Dec 2011 04:02:03 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Fri, 16 Dec 2011 13:01:51 +0100 Message-Id: <1324036918-2405-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1324036918-2405-1-git-send-email-pbonzini@redhat.com> References: <1324036918-2405-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 1/8] qapi: fix NULL pointer dereference List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com 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 --- 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