Skip to content

Commit 2eccf56

Browse files
committed
Use large count in the boundFunction call
We can get large count in the boundfunction new instance. We should be using the large count variant API to get the count (OS#17406027)
1 parent 16de442 commit 2eccf56

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lib/Runtime/Library/BoundFunction.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,13 @@ namespace Js
177177
// OACR thinks that this can change between here and the check in the for loop below
178178
const unsigned int argCount = args.Info.Count;
179179

180-
if ((boundFunction->count + args.GetArgCountWithExtraArgs()) > CallInfo::kMaxCountArgs)
180+
uint32 newArgCount = UInt32Math::Add(boundFunction->count, args.GetLargeArgCountWithExtraArgs());
181+
if (newArgCount > CallInfo::kMaxCountArgs)
181182
{
182183
JavascriptError::ThrowRangeError(scriptContext, JSERR_ArgListTooLarge);
183184
}
184185

185-
Field(Var) *newValues = RecyclerNewArray(scriptContext->GetRecycler(), Field(Var), boundFunction->count + args.GetArgCountWithExtraArgs());
186+
Field(Var) *newValues = RecyclerNewArray(scriptContext->GetRecycler(), Field(Var), newArgCount);
186187

187188
uint index = 0;
188189

@@ -218,7 +219,7 @@ namespace Js
218219
actualArgs = Arguments(args.Info, unsafe_write_barrier_cast<Var*>(newValues));
219220
actualArgs.Info.Count = boundFunction->count + argCount;
220221

221-
Assert(index == actualArgs.GetArgCountWithExtraArgs());
222+
Assert(index == actualArgs.GetLargeArgCountWithExtraArgs());
222223
}
223224
else
224225
{

test/Bugs/misc_bugs.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ var tests = [
130130
function foo() {}
131131
Reflect.construct(foo, new Array(2**16-2));
132132
} catch(e) { }
133+
134+
try {
135+
function foo() {}
136+
var bar = foo.bind({}, 1);
137+
new bar(...(new Array(2**16+1)))
138+
} catch(e) { }
133139
}
134140
}
135141

0 commit comments

Comments
 (0)