diff options
author | Andreas Kling <kling@serenityos.org> | 2022-09-21 10:36:29 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-09-21 11:51:18 +0200 |
commit | b02402e116da46d8ec51d3e418f83d12b8377fbe (patch) | |
tree | 68385db7428d253c0b92e36e9efc445e8b0498bb /Userland | |
parent | 68d0f303681f0352e31d5523925f78d0f0616e05 (diff) | |
download | serenity-b02402e116da46d8ec51d3e418f83d12b8377fbe.zip |
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.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibWeb/Loader/Resource.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/Loader/Resource.cpp b/Userland/Libraries/LibWeb/Loader/Resource.cpp index eaf79fa751..931c1327da 100644 --- a/Userland/Libraries/LibWeb/Loader/Resource.cpp +++ b/Userland/Libraries/LibWeb/Loader/Resource.cpp @@ -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; + } }); } } |