Skip to content

Commit

Permalink
[MERGE #6105 @akroshg] The allignment in the else block can increase …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
akroshg committed Apr 17, 2019
2 parents 5e9cba3 + 370e0ac commit f0a7e8a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/Runtime/Library/JavascriptArray.cpp
Expand Up @@ -11917,6 +11917,7 @@ using namespace Js;
SparseArraySegment<typename T::TElement>* src = SparseArraySegment<typename T::TElement>::From(instance->head);
SparseArraySegment<typename T::TElement>* dst;

uint32 sourceSize = src->size;
if (IsInlineSegment(src, instance))
{
// Copy head segment data between inlined head segments
Expand All @@ -11925,6 +11926,7 @@ using namespace Js;
dst->length = src->length;
uint inlineChunkSize = SparseArraySegmentBase::INLINE_CHUNK_SIZE;
dst->size = min(src->size, inlineChunkSize);
sourceSize = dst->size;
}
else
{
Expand All @@ -11939,8 +11941,7 @@ using namespace Js;

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

AssertOrFailFast(dst->size <= src->size);
CopyArray(dst->elements, dst->size, src->elements, dst->size);
CopyArray(dst->elements, dst->size, src->elements, sourceSize);

if (!deepCopy)
{
Expand Down

0 comments on commit f0a7e8a

Please sign in to comment.