1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 06:28:13 +00: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

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;
}
});
}
}