mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-02-02 10:21:10 +00:00
qobject: Protect against use-after-free in qobject_decref()
Adding an assertion to qobject_decref() will ensure that a programming error causing use-after-free will result in immediate failure (provided no other thread has started using the memory) instead of silently attempting to wrap refcnt around and leaving the problem to potentially bite later at a harder point to diagnose. Backports commit cc9f60d4a2a4bf2578a9309a18f1c4602c9f5ce7 from qemu
This commit is contained in:
parent
ba067e4411
commit
6bd4bc814f
|
@ -94,6 +94,7 @@ static inline void qobject_incref(QObject *obj)
|
|||
*/
|
||||
static inline void qobject_decref(QObject *obj)
|
||||
{
|
||||
assert(!obj || obj->refcnt);
|
||||
if (obj && --obj->refcnt == 0) {
|
||||
assert(obj->type != NULL);
|
||||
assert(obj->type->destroy != NULL);
|
||||
|
|
Loading…
Reference in a new issue