summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-09-21 10:36:29 +0200
committerAndreas Kling <kling@serenityos.org>2022-09-21 11:51:18 +0200
commitb02402e116da46d8ec51d3e418f83d12b8377fbe (patch)
tree68385db7428d253c0b92e36e9efc445e8b0498bb /Userland
parent68d0f303681f0352e31d5523925f78d0f0616e05 (diff)
downloadserenity-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.cpp8
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;
+ }
});
}
}