mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 20:57:35 +00:00
LibJS: Don't assume a this argument for function.prototype.bind
Assuming we had at least one argument meant that the ...arg count would underflow causing the bound function to have length 0 instead of the given length when binding with no arguments.
This commit is contained in:
parent
c4f3d44be1
commit
9d05ca7b20
2 changed files with 14 additions and 1 deletions
|
@ -103,7 +103,7 @@ JS_DEFINE_NATIVE_FUNCTION(FunctionPrototype::bind)
|
|||
auto* function = TRY(BoundFunction::create(global_object, target, this_argument, move(arguments)));
|
||||
|
||||
// 4. Let argCount be the number of elements in args.
|
||||
auto arg_count = vm.argument_count() - 1;
|
||||
auto arg_count = vm.argument_count() > 0 ? vm.argument_count() - 1 : 0;
|
||||
|
||||
// 5. Perform ? CopyNameAndLength(F, Target, "bound", argCount).
|
||||
TRY(copy_name_and_length(global_object, *function, target, "bound"sv, arg_count));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue