mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 09:49:15 +03:00
LibThreading: Fix BackgroundAction result use-after-free
We need to move the result out of the BackgroundAction object before posting the completion callback as there is a chance the BackgroundAction instance gets freed before the event loop runs our callback. Fixes #7641
This commit is contained in:
parent
8aafbd917a
commit
b2e6088bff
Notes:
sideshowbarker
2024-07-18 10:22:47 +09:00
Author: https://github.com/tomuta Commit: https://github.com/SerenityOS/serenity/commit/b2e6088bff2 Pull-request: https://github.com/SerenityOS/serenity/pull/8461 Issue: https://github.com/SerenityOS/serenity/issues/7641
@ -66,8 +66,8 @@ private:
|
||||
enqueue_work([this] {
|
||||
m_result = m_action(*this);
|
||||
if (m_on_complete) {
|
||||
Core::EventLoop::current().post_event(*this, make<Core::DeferredInvocationEvent>([this](auto&) {
|
||||
m_on_complete(m_result.release_value());
|
||||
Core::EventLoop::current().post_event(*this, make<Core::DeferredInvocationEvent>([this, result = m_result.release_value()](auto&) {
|
||||
m_on_complete(result);
|
||||
this->remove_from_parent();
|
||||
}));
|
||||
Core::EventLoop::wake();
|
||||
|
Loading…
Reference in New Issue
Block a user