aboutsummaryrefslogtreecommitdiff
path: root/qobject
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2015-10-15 16:15:34 +0200
committerMarkus Armbruster <armbru@redhat.com>2015-10-29 14:34:45 +0100
commit89cad9f3ec6b30d7550fb5704475fc9c3393a066 (patch)
tree8dc83797bad950cc5fc6f69215032cd2b120840e /qobject
parent14b6160099f0caf5dc9d62e637b007bc5d719a96 (diff)
qdict: Make conversion from QObject * accept null
qobject_to_qdict() crashes on null, which is a trap for the unwary. Return null instead, and simplify a few callers. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1444918537-18107-4-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'qobject')
-rw-r--r--qobject/qdict.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/qobject/qdict.c b/qobject/qdict.c
index f179f4e8ca..6b322850dc 100644
--- a/qobject/qdict.c
+++ b/qobject/qdict.c
@@ -46,9 +46,9 @@ QDict *qdict_new(void)
*/
QDict *qobject_to_qdict(const QObject *obj)
{
- if (qobject_type(obj) != QTYPE_QDICT)
+ if (!obj || qobject_type(obj) != QTYPE_QDICT) {
return NULL;
-
+ }
return container_of(obj, QDict, base);
}
@@ -269,7 +269,7 @@ QList *qdict_get_qlist(const QDict *qdict, const char *key)
*/
QDict *qdict_get_qdict(const QDict *qdict, const char *key)
{
- return qobject_to_qdict(qdict_get_obj(qdict, key, QTYPE_QDICT));
+ return qobject_to_qdict(qdict_get(qdict, key));
}
/**