Skip to content

Commit 9df80f1

Browse files
committed
[MERGE #5253 @akroshg] Use large count in the boundFunction call
Merge pull request #5253 from akroshg:largecount1 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)
2 parents 95e1c2b + 2eccf56 commit 9df80f1

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)