diff options
author | Linus Groh <mail@linusgroh.de> | 2021-09-12 12:52:37 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-12 15:18:25 +0200 |
commit | c5bd38252498e822ecb242e680f78e58448950a8 (patch) | |
tree | 375d314c23297f7d9483aff5d96f2d9936e79c01 /Userland/Libraries/LibJS | |
parent | 7b92889e6bbafba2fcc74b9048fa5f05f07ce528 (diff) | |
download | serenity-c5bd38252498e822ecb242e680f78e58448950a8.zip |
LibJS: Leave NativeFunction's Realm unset if VM has no Interpreter
There's currently a fallback at the call site where the Realm is needed
(due to a slightly incorrect implementation of [[Call]] / [[Construct]])
so this is better than crashing (in LibWeb, currently).
Diffstat (limited to 'Userland/Libraries/LibJS')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/NativeFunction.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp index e784d3aa97..4f3916cc4b 100644 --- a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp @@ -22,7 +22,7 @@ NativeFunction* NativeFunction::create(GlobalObject& global_object, const FlyStr NativeFunction::NativeFunction(Object& prototype) : FunctionObject(prototype) - , m_realm(&vm().interpreter().realm()) + , m_realm(vm().interpreter_if_exists() ? &vm().interpreter().realm() : nullptr) { } @@ -30,14 +30,14 @@ NativeFunction::NativeFunction(FlyString name, Function<Value(VM&, GlobalObject& : FunctionObject(prototype) , m_name(move(name)) , m_native_function(move(native_function)) - , m_realm(&vm().interpreter().realm()) + , m_realm(vm().interpreter_if_exists() ? &vm().interpreter().realm() : nullptr) { } NativeFunction::NativeFunction(FlyString name, Object& prototype) : FunctionObject(prototype) , m_name(move(name)) - , m_realm(&vm().interpreter().realm()) + , m_realm(vm().interpreter_if_exists() ? &vm().interpreter().realm() : nullptr) { } |