Skip to content

Commit 1d7f0cf

Browse files
committed
convert copyonaccess arrays for Array.push
1 parent 0fd7555 commit 1d7f0cf

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/Runtime/Library/JavascriptArray.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5365,6 +5365,11 @@ using namespace Js;
53655365
Var JavascriptArray::EntryPushJavascriptArray(ScriptContext * scriptContext, Var * args, uint argCount)
53665366
{
53675367
JavascriptArray * arr = JavascriptArray::FromAnyArray(args[0]);
5368+
5369+
#if ENABLE_COPYONACCESS_ARRAY
5370+
JavascriptLibrary::CheckAndConvertCopyOnAccessNativeIntArray<Var>(arr);
5371+
#endif
5372+
53685373
uint n = arr->length;
53695374
ThrowTypeErrorOnFailureHelper h(scriptContext, _u("Array.prototype.push"));
53705375

test/Array/CopyOnAccessArray_bugs.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ var tests = [
2626
var a=[1,2];
2727
Array.prototype.push.call(a,1);
2828
assert.areEqual([1,2,1], a, "Incorrect result from Array.prototype.push()");
29+
30+
Array.prototype.push.call([0, 0, 0, 0, 0]);
2931
}
3032
},
3133
{

0 commit comments

Comments
 (0)