Skip to content

Commit f0a7e8a

Browse files
committed
[MERGE #6105 @akroshg] The allignment in the else block can increase the size of the dst->size.
Merge pull request #6105 from akroshg:assertfix Fixed this by taking the min value to copy from the source.
2 parents 5e9cba3 + 370e0ac commit f0a7e8a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/Runtime/Library/JavascriptArray.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11917,6 +11917,7 @@ using namespace Js;
1191711917
SparseArraySegment<typename T::TElement>* src = SparseArraySegment<typename T::TElement>::From(instance->head);
1191811918
SparseArraySegment<typename T::TElement>* dst;
1191911919

11920+
uint32 sourceSize = src->size;
1192011921
if (IsInlineSegment(src, instance))
1192111922
{
1192211923
// Copy head segment data between inlined head segments
@@ -11925,6 +11926,7 @@ using namespace Js;
1192511926
dst->length = src->length;
1192611927
uint inlineChunkSize = SparseArraySegmentBase::INLINE_CHUNK_SIZE;
1192711928
dst->size = min(src->size, inlineChunkSize);
11929+
sourceSize = dst->size;
1192811930
}
1192911931
else
1193011932
{
@@ -11939,8 +11941,7 @@ using namespace Js;
1193911941

1194011942
Assert(IsInlineSegment(src, instance) == IsInlineSegment(dst, static_cast<T*>(this)));
1194111943

11942-
AssertOrFailFast(dst->size <= src->size);
11943-
CopyArray(dst->elements, dst->size, src->elements, dst->size);
11944+
CopyArray(dst->elements, dst->size, src->elements, sourceSize);
1194411945

1194511946
if (!deepCopy)
1194611947
{

0 commit comments

Comments
 (0)