LibWeb: Sever parent/child connections in ~TreeNode()
Also make sure to unref the children if there are any. Without this it was very easy to leak TreeNodes.
This commit is contained in:
parent
41e5a0fe02
commit
c70e0a4f29
Notes:
sideshowbarker
2024-07-18 20:43:50 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/c70e0a4f294
1 changed files with 11 additions and 0 deletions
|
@ -299,6 +299,17 @@ public:
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
~TreeNode()
|
||||
{
|
||||
VERIFY(!m_parent);
|
||||
T* next_child = nullptr;
|
||||
for (auto* child = m_first_child; child; child = next_child) {
|
||||
next_child = child->m_next_sibling;
|
||||
child->m_parent = nullptr;
|
||||
child->unref();
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
TreeNode() { }
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue