mirror of
https://github.com/yuzu-emu/unicorn
synced 2024-11-25 10:08:51 +00:00
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. Backports commit 89cad9f3ec6b30d7550fb5704475fc9c3393a066 from qemu
This commit is contained in:
parent
41ca5bddb8
commit
3f0b32f1ee
1 changed files with 3 additions and 3 deletions
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue