summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorkleines Filmröllchen <filmroellchen@serenityos.org>2023-05-11 22:00:22 +0200
committerAndrew Kaster <andrewdkaster@gmail.com>2023-05-17 22:40:15 -0600
commit04b44a827a2ec494995e6583fb398835cf887eb3 (patch)
treeac9e280345682a999f5701a508cac4071c6cfd89 /Userland
parent7704d894965b87c162efdce37dbcb5939579a91f (diff)
downloadserenity-04b44a827a2ec494995e6583fb398835cf887eb3.zip
LibThreading: Only run on_error callback when action wasn't canceled
This mirrors the same UAF protection for event loops used by the on_complete callback.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibThreading/BackgroundAction.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/Userland/Libraries/LibThreading/BackgroundAction.h b/Userland/Libraries/LibThreading/BackgroundAction.h
index 7ea18e1819..9376e7e996 100644
--- a/Userland/Libraries/LibThreading/BackgroundAction.h
+++ b/Userland/Libraries/LibThreading/BackgroundAction.h
@@ -100,13 +100,15 @@ private:
error = result.release_error();
m_promise->cancel(Error::from_errno(ECANCELED));
- if (m_on_error) {
+ if (!m_canceled && m_on_error) {
callback_scheduled = true;
origin_event_loop->deferred_invoke([this, error = move(error)]() mutable {
m_on_error(move(error));
remove_from_parent();
});
origin_event_loop->wake();
+ } else if (m_on_error) {
+ m_on_error(move(error));
}
}