diff --git a/repos/base-hw/src/core/kernel/object.cc b/repos/base-hw/src/core/kernel/object.cc index fdd4006138..9312961be7 100644 --- a/repos/base-hw/src/core/kernel/object.cc +++ b/repos/base-hw/src/core/kernel/object.cc @@ -26,12 +26,16 @@ void Object_identity::invalidate() { for (Object_identity_reference * oir = first(); oir; oir = first()) oir->invalidate(); - _object.remove(this); + + if (_object) { + _object->remove(this); + _object = nullptr; + } } Object_identity::Object_identity(Object & object) -: _object(object) { _object.insert(this); } +: _object(&object) { _object->insert(this); } Object_identity::~Object_identity() { invalidate(); } diff --git a/repos/base-hw/src/core/kernel/object.h b/repos/base-hw/src/core/kernel/object.h index 9dc6bad884..55cce9a820 100644 --- a/repos/base-hw/src/core/kernel/object.h +++ b/repos/base-hw/src/core/kernel/object.h @@ -83,7 +83,7 @@ class Kernel::Object_identity { private: - Object & _object; + Object * _object = nullptr; public: @@ -91,7 +91,7 @@ class Kernel::Object_identity ~Object_identity(); template - KOBJECT * object() { return dynamic_cast(&_object); } + KOBJECT * object() { return dynamic_cast(_object); } void invalidate(); };