mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-11-21 16:37:20 +01:00
Object::call()
prevent debug lock accessing dangling pointer
Self deleting an object within a call was leading to crashes due to referencing freed memory, due to a raw pointer stored in the debug lock. Co-authored-by: RandomShaper <pedrojrulez@gmail.com>
This commit is contained in:
parent
fabd5c32f5
commit
78b9753e37
@ -44,14 +44,17 @@
|
||||
#ifdef DEBUG_ENABLED
|
||||
|
||||
struct _ObjectDebugLock {
|
||||
Object *obj;
|
||||
ObjectID obj_id;
|
||||
|
||||
_ObjectDebugLock(Object *p_obj) {
|
||||
obj = p_obj;
|
||||
obj->_lock_index.ref();
|
||||
obj_id = p_obj->get_instance_id();
|
||||
p_obj->_lock_index.ref();
|
||||
}
|
||||
~_ObjectDebugLock() {
|
||||
obj->_lock_index.unref();
|
||||
Object *obj_ptr = ObjectDB::get_instance(obj_id);
|
||||
if (likely(obj_ptr)) {
|
||||
obj_ptr->_lock_index.unref();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user