From 14f2012c8bf4f22e5965ee73a0b566ade810f693 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 30 Mar 2024 08:16:03 +0100 Subject: [PATCH] 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. --- Userland/Libraries/LibWeb/WebAudio/AudioContext.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Userland/Libraries/LibWeb/WebAudio/AudioContext.cpp b/Userland/Libraries/LibWeb/WebAudio/AudioContext.cpp index 7fc1ad07f6..33d2e7e744 100644 --- a/Userland/Libraries/LibWeb/WebAudio/AudioContext.cpp +++ b/Userland/Libraries/LibWeb/WebAudio/AudioContext.cpp @@ -155,10 +155,10 @@ WebIDL::ExceptionOr> AudioContext::resume() } // 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. - for (auto const& promise : m_pending_resume_promises) { - *promise->resolve(); + for (auto const& pending_resume_promise : m_pending_resume_promises) { + *pending_resume_promise->resolve(); } // 7.5.2: Clear [[pending resume promises]]. @@ -220,7 +220,7 @@ WebIDL::ExceptionOr> AudioContext::suspend() set_rendering_state(Bindings::AudioContextState::Suspended); // 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. *promise->resolve(); @@ -270,7 +270,7 @@ WebIDL::ExceptionOr> AudioContext::close() // 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: - queue_a_media_element_task([&realm, &promise, this]() { + queue_a_media_element_task([&realm, promise, this]() { // 5.4.1: Resolve promise. *promise->resolve();