浏览代码

LibCore: Remove unnecessary or invalid write after child remove

MINAqwq 1 年之前
父节点
当前提交
e1598233e1
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      Userland/Libraries/LibCore/EventReceiver.h

+ 3 - 1
Userland/Libraries/LibCore/EventReceiver.h

@@ -134,7 +134,9 @@ public:
     {
         if (m_parent)
             m_parent->remove_child(*this);
-        m_parent = nullptr;
+
+        // The call to `remove_child` may have deleted the object.
+        // Do not dereference `this` from this point forward.
     }
 
     template<class T, class... Args>