1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 18:20:43 +09:00

LibWeb: Fix null dereference in ResourceClient::set_resource()

If resource_did_load() results in the ResourceClient being destroyed,
we can't dereference the weak ResourceClient right after.
This commit is contained in:
Andreas Kling 2022-09-21 10:36:29 +02:00
parent 68d0f30368
commit b02402e116
Notes: sideshowbarker 2024-07-17 06:45:52 +09:00

View file

@ -176,12 +176,16 @@ void ResourceClient::set_resource(Resource* resource)
return;
// Make sure that reused resources also have their load callback fired.
if (weak_this->m_resource->is_loaded())
if (weak_this->m_resource->is_loaded()) {
weak_this->resource_did_load();
return;
}
// Make sure that reused resources also have their fail callback fired.
if (weak_this->m_resource->is_failed())
if (weak_this->m_resource->is_failed()) {
weak_this->resource_did_fail();
return;
}
});
}
}