mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-07 19:57:45 +03: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:
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
@ -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…
Reference in New Issue
Block a user