mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:38:11 +00:00
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.
This commit is contained in:
parent
7704d89496
commit
04b44a827a
1 changed files with 3 additions and 1 deletions
|
@ -100,13 +100,15 @@ private:
|
||||||
error = result.release_error();
|
error = result.release_error();
|
||||||
|
|
||||||
m_promise->cancel(Error::from_errno(ECANCELED));
|
m_promise->cancel(Error::from_errno(ECANCELED));
|
||||||
if (m_on_error) {
|
if (!m_canceled && m_on_error) {
|
||||||
callback_scheduled = true;
|
callback_scheduled = true;
|
||||||
origin_event_loop->deferred_invoke([this, error = move(error)]() mutable {
|
origin_event_loop->deferred_invoke([this, error = move(error)]() mutable {
|
||||||
m_on_error(move(error));
|
m_on_error(move(error));
|
||||||
remove_from_parent();
|
remove_from_parent();
|
||||||
});
|
});
|
||||||
origin_event_loop->wake();
|
origin_event_loop->wake();
|
||||||
|
} else if (m_on_error) {
|
||||||
|
m_on_error(move(error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue