From dfed8f61cb421a43a4d84456a74f422cd4641632 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Wed, 30 Jun 2021 18:48:55 +0300 Subject: [PATCH] LibJS: Use the GetFunctionRealm abstract-op in ArraySpeciesCreate --- Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp index ba19df38d7..e535f62936 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp @@ -159,11 +159,12 @@ static Object* array_species_create(GlobalObject& global_object, Object& origina return {}; if (constructor.is_constructor()) { auto& constructor_function = constructor.as_function(); - if (&constructor_function.global_object() != &global_object) { - auto* array_constructor = constructor_function.global_object().array_constructor(); - if (&constructor_function == array_constructor) { + auto* constructor_realm = get_function_realm(global_object, constructor_function); + if (vm.exception()) + return {}; + if (constructor_realm != &global_object) { + if (&constructor_function == constructor_realm->array_constructor()) constructor = js_undefined(); - } } }