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

LibWeb: Don't access SharedImageRequest::m_document in destructor

It's not safe to access m_document here since GC may have deleted it
by the time we're being deleted. Instead, move this to a finalize()
override, since those are guaranteed to be called while both objects
are still alive.
This commit is contained in:
Andreas Kling 2023-12-23 20:50:23 +01:00
parent 6c1fcc5f7e
commit 41941aeb10
2 changed files with 9 additions and 5 deletions

View file

@ -40,8 +40,11 @@ SharedImageRequest::SharedImageRequest(JS::NonnullGCPtr<Page> page, AK::URL url,
{
}
SharedImageRequest::~SharedImageRequest()
SharedImageRequest::~SharedImageRequest() = default;
void SharedImageRequest::finalize()
{
Base::finalize();
auto& shared_image_requests = m_document->shared_image_requests();
shared_image_requests.remove(m_url);
}