mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-24 19:21:52 +00:00
LibJS/Bytecode: Check if eval function is a function
When overriding 'eval' to a non-function value, the interpreter would crash. Now it handles this case swiftly, throwing a TypeError.
This commit is contained in:
parent
a9ef65e64a
commit
1850652881
Notes:
sideshowbarker
2024-07-17 05:09:48 +09:00
Author: https://github.com/cg-jl
Commit: 1850652881
Pull-request: https://github.com/SerenityOS/serenity/pull/21861
2 changed files with 7 additions and 1 deletions
|
@ -233,7 +233,8 @@ static Completion throw_type_error_for_callee(Bytecode::Interpreter& interpreter
|
|||
|
||||
ThrowCompletionOr<void> throw_if_needed_for_call(Interpreter& interpreter, Value callee, Op::CallType call_type, Optional<StringTableIndex> const& expression_string)
|
||||
{
|
||||
if (call_type == Op::CallType::Call && !callee.is_function())
|
||||
if ((call_type == Op::CallType::Call || call_type == Op::CallType::DirectEval)
|
||||
&& !callee.is_function())
|
||||
return throw_type_error_for_callee(interpreter, callee, "function"sv, expression_string);
|
||||
if (call_type == Op::CallType::Construct && !callee.is_constructor())
|
||||
return throw_type_error_for_callee(interpreter, callee, "constructor"sv, expression_string);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue