From 3c3f1f9fad557e70877029f2007602772093f167 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Wed, 30 Jul 2025 05:05:00 +0200 Subject: [PATCH] LibWeb: Don't capture proxy as root in `ProxyConstructor::revocable` `revoker_closure` is used to construct `NativeFunction` that visits `raw_capture_range()`, so there is no need to use GC root for `proxy`. --- Libraries/LibJS/Runtime/ProxyConstructor.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Libraries/LibJS/Runtime/ProxyConstructor.cpp b/Libraries/LibJS/Runtime/ProxyConstructor.cpp index 10ac30b2682..a9c2c7bca6c 100644 --- a/Libraries/LibJS/Runtime/ProxyConstructor.cpp +++ b/Libraries/LibJS/Runtime/ProxyConstructor.cpp @@ -86,21 +86,19 @@ JS_DEFINE_NATIVE_FUNCTION(ProxyConstructor::revocable) auto* proxy = TRY(proxy_create(vm, target, handler)); // 2. Let revokerClosure be a new Abstract Closure with no parameters that captures nothing and performs the following steps when called: - auto revoker_closure = [proxy_handle = make_root(proxy)](auto&) -> ThrowCompletionOr { + auto revoker_closure = [proxy](auto&) -> ThrowCompletionOr { // a. Let F be the active function object. // b. Let p be F.[[RevocableProxy]]. - auto& proxy = const_cast(*proxy_handle.cell()); - // c. If p is null, return undefined. - if (proxy.is_revoked()) + if (proxy->is_revoked()) return js_undefined(); // d. Set F.[[RevocableProxy]] to null. // e. Assert: p is a Proxy object. // f. Set p.[[ProxyTarget]] to null. // g. Set p.[[ProxyHandler]] to null. - proxy.revoke(); + proxy->revoke(); // h. Return undefined. return js_undefined();