1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:37:34 +00:00

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:
Andreas Kling 2021-04-06 15:50:47 +02:00
parent 41e5a0fe02
commit c70e0a4f29

View file

@ -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() { }