From 3bcd368703a41deb6d6a2bb02ddae444014a6801 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Tue, 26 Sep 2023 16:47:29 +0200 Subject: [PATCH] LibWeb: Do not pass JS::Handle into NativeFunction callback captures NativeFunction uses JS::HeapFunction for the callback so GC-allocated captures will be visited anyway. --- Userland/Libraries/LibWeb/DOM/EventTarget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp index d85556d87f..dc999602ce 100644 --- a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp +++ b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp @@ -561,7 +561,7 @@ void EventTarget::activate_event_handler(FlyString const& name, HTML::EventHandl // location.reload(); // The body element is no longer in the DOM and there is no variable holding onto it. However, the onunload handler is still called, meaning the callback keeps the body element alive. auto callback_function = JS::NativeFunction::create( - realm, [event_target = JS::make_handle(*this), name](JS::VM& vm) mutable -> JS::ThrowCompletionOr { + realm, [event_target = this, name](JS::VM& vm) mutable -> JS::ThrowCompletionOr { // The event dispatcher should only call this with one argument. VERIFY(vm.argument_count() == 1);