From d25b8420d09ca3633ddf750007aeb22030b38bf7 Mon Sep 17 00:00:00 2001
From: Markus Armbruster <armbru@redhat.com>
Date: Sat, 17 Feb 2018 14:21:26 -0500
Subject: [PATCH] qlist: Make conversion from QObject * accept null

qobject_to_qlist() crashes on null, which is a trap for the unwary.
Return null instead.

Backports commit 2d6421a90047a83f6722832405fe09571040ea5b from qemu
---
 qemu/qobject/qlist.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/qemu/qobject/qlist.c b/qemu/qobject/qlist.c
index 60ce805d..a54f9ffb 100644
--- a/qemu/qobject/qlist.c
+++ b/qemu/qobject/qlist.c
@@ -142,10 +142,9 @@ size_t qlist_size(const QList *qlist)
  */
 QList *qobject_to_qlist(const QObject *obj)
 {
-    if (qobject_type(obj) != QTYPE_QLIST) {
+    if (!obj || qobject_type(obj) != QTYPE_QLIST) {
         return NULL;
     }
-
     return container_of(obj, QList, base);
 }