Skip to content

Commit 348cd33

Browse files
committed
Array.prototype.unshift does not marshal parameters correctly
Fixes OS 9357224. Array.prototype.unshift does not take the slow path if 'this' is a cross-site object.
1 parent ee8e57e commit 348cd33

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

lib/Runtime/Library/JavascriptArray.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7563,7 +7563,7 @@ namespace Js
75637563
{
75647564
return res;
75657565
}
7566-
if (JavascriptArray::Is(args[0]))
7566+
if (JavascriptArray::Is(args[0]) && !JavascriptArray::FromVar(args[0])->IsCrossSiteObject())
75677567
{
75687568
#if ENABLE_COPYONACCESS_ARRAY
75697569
JavascriptLibrary::CheckAndConvertCopyOnAccessNativeIntArray<Var>(args[0]);

test/Array/shift_unshift.baseline

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ e instanceOf TypeError = true
4848
a.length = 1
4949
ary.length = 18
5050
arr.length = 6
51+
Crosssite new length: 2
5152
Overridden unshift
5253
Overridden unshift
5354
Overridden unshift

test/Array/shift_unshift.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,14 @@ function test1(arr)
140140

141141
WScript.Echo("arr.length = " + test1(new Array(10)));
142142

143+
// OS 9357224: Array.prototype.unshift does not marshal parameters correctly
144+
function crossSiteUnshift() {
145+
var sc0 = WScript.LoadScript('', 'samethread');
146+
sc0.ary = [1];
147+
return sc0.eval('Array.prototype.unshift.call(ary, null)');
148+
}
149+
WScript.Echo("Crosssite new length: " + crossSiteUnshift()); // 2
150+
143151
//
144152
// To check bailouts for inlined unshift
145153
//
@@ -164,4 +172,3 @@ function foo()
164172
Array.prototype.unshift = function(){WScript.Echo ("Overridden unshift")};
165173
foo();
166174
WScript.Echo (a);
167-

0 commit comments

Comments
 (0)