1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:28:11 +00:00

LibWeb: Add GC finalizer to DOM::NodeIterator

It's potentially unsafe to access `m_root` in the destructor since it
may have been swept, so move unregistration of the NodeIterator into a
GC finalizer instead.
This commit is contained in:
Andreas Kling 2022-10-20 19:46:39 +02:00
parent e7da96acaf
commit eda566d112
2 changed files with 5 additions and 1 deletions

View file

@ -19,8 +19,11 @@ NodeIterator::NodeIterator(Node& root)
root.document().register_node_iterator({}, *this);
}
NodeIterator::~NodeIterator()
NodeIterator::~NodeIterator() = default;
void NodeIterator::finalize()
{
Base::finalize();
m_root->document().unregister_node_iterator({}, *this);
}