Skip to content

Commit 8ec116d

Browse files
committed
[MERGE #5164 @akroshg] Should use large count (OS# 17406027)
Merge pull request #5164 from akroshg:largecount We didn't pass 'useLargeArgsCount' in these scenarios, which are legitimate cases. Entrycall, cross-site and Reflect.construct Fixed them.
2 parents 9b43fd7 + acf629e commit 8ec116d

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

lib/Runtime/Base/CrossSite.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ namespace Js
464464

465465
if (callerHostScriptContext == calleeHostScriptContext || (callerHostScriptContext == nullptr && !calleeHostScriptContext->HasCaller()))
466466
{
467-
return JavascriptFunction::CallFunction<true>(function, entryPoint, args);
467+
return JavascriptFunction::CallFunction<true>(function, entryPoint, args, true /*useLargeArgCount*/);
468468
}
469469

470470
#if DBG_DUMP || defined(PROFILE_EXEC) || defined(PROFILE_MEM)
@@ -536,7 +536,7 @@ namespace Js
536536
}
537537
wasDispatchExCallerPushed = TRUE;
538538

539-
result = JavascriptFunction::CallFunction<true>(function, entryPoint, args);
539+
result = JavascriptFunction::CallFunction<true>(function, entryPoint, args, true /*useLargeArgCount*/);
540540
ScriptContext* callerScriptContext = callerHostScriptContext->GetScriptContext();
541541
result = CrossSite::MarshalVar(callerScriptContext, result);
542542
},

lib/Runtime/Library/JavascriptFunction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ namespace Js
644644
///
645645
/// Call the [[Call]] method on the function object
646646
///
647-
return JavascriptFunction::CallFunction<true>(pFunc, pFunc->GetEntryPoint(), args);
647+
return JavascriptFunction::CallFunction<true>(pFunc, pFunc->GetEntryPoint(), args, true /*useLargeArgCount*/);
648648
}
649649

650650
Var JavascriptFunction::CallRootFunctionInScript(JavascriptFunction* func, Arguments args)
@@ -930,7 +930,7 @@ namespace Js
930930
}
931931
else
932932
{
933-
functionResult = CallFunction<true>(functionObj, functionObj->GetEntryPoint(), newArgs);
933+
functionResult = CallFunction<true>(functionObj, functionObj->GetEntryPoint(), newArgs, true /*useLargeArgCount*/);
934934
}
935935

936936
return

test/Bugs/misc_bugs.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,38 @@ var tests = [
9999

100100
assert.throws(()=> {arr.splice(4294967290, 0, 200, 201, 202, 203, 204, 205, 206);});
101101
}
102+
},
103+
{
104+
name: "Passing args count near 2**16 should not fire assert (OS# 17406027)",
105+
body: function () {
106+
try {
107+
eval.call(...(new Array(2**16)));
108+
} catch (e) { }
109+
110+
try {
111+
eval.call(...(new Array(2**16+1)));
112+
} catch (e) { }
113+
114+
try {
115+
var sc1 = WScript.LoadScript(`function foo() {}`, "samethread");
116+
sc1.foo(...(new Array(2**16)));
117+
} catch(e) { }
118+
119+
try {
120+
var sc2 = WScript.LoadScript(`function foo() {}`, "samethread");
121+
sc2.foo(...(new Array(2**16+1)));
122+
} catch(e) { }
123+
124+
try {
125+
function foo() {}
126+
Reflect.construct(foo, new Array(2**16-3));
127+
} catch(e) { }
128+
129+
try {
130+
function foo() {}
131+
Reflect.construct(foo, new Array(2**16-2));
132+
} catch(e) { }
133+
}
102134
}
103135

104136
];

0 commit comments

Comments
 (0)