1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 10:18:15 +09:00

LibWeb: Fix a bunch of bad stack captures in AudioContext

It's not safe to capture a local NonnullGCPtr by reference in a closure
that will execute at some arbitrary time in the future when the local is
out of scope.
This commit is contained in:
Andreas Kling 2024-03-30 08:16:03 +01:00
parent 6103884c18
commit 14f2012c8b
Notes: sideshowbarker 2024-07-17 03:45:48 +09:00

View file

@ -155,10 +155,10 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> AudioContext::resume()
} }
// 7.5: queue a media element task to execute the following steps: // 7.5: queue a media element task to execute the following steps:
queue_a_media_element_task([&realm, &promise, this]() { queue_a_media_element_task([&realm, promise, this]() {
// 7.5.1: Resolve all promises from [[pending resume promises]] in order. // 7.5.1: Resolve all promises from [[pending resume promises]] in order.
for (auto const& promise : m_pending_resume_promises) { for (auto const& pending_resume_promise : m_pending_resume_promises) {
*promise->resolve(); *pending_resume_promise->resolve();
} }
// 7.5.2: Clear [[pending resume promises]]. // 7.5.2: Clear [[pending resume promises]].
@ -220,7 +220,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> AudioContext::suspend()
set_rendering_state(Bindings::AudioContextState::Suspended); set_rendering_state(Bindings::AudioContextState::Suspended);
// 7.3: queue a media element task to execute the following steps: // 7.3: queue a media element task to execute the following steps:
queue_a_media_element_task([&realm, &promise, this]() { queue_a_media_element_task([&realm, promise, this]() {
// 7.3.1: Resolve promise. // 7.3.1: Resolve promise.
*promise->resolve(); *promise->resolve();
@ -270,7 +270,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> AudioContext::close()
// FIXME: 5.3: If this control message is being run in a reaction to the document being unloaded, abort this algorithm. // FIXME: 5.3: If this control message is being run in a reaction to the document being unloaded, abort this algorithm.
// 5.4: queue a media element task to execute the following steps: // 5.4: queue a media element task to execute the following steps:
queue_a_media_element_task([&realm, &promise, this]() { queue_a_media_element_task([&realm, promise, this]() {
// 5.4.1: Resolve promise. // 5.4.1: Resolve promise.
*promise->resolve(); *promise->resolve();