Skip to content

Commit 0578ca5

Browse files
akroshgrajatd
authored andcommitted
[CVE-2018-0994] Edge - Submit a use after free bug to Edge - 360Vulcan
1 parent 91dc6f8 commit 0578ca5

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/Runtime/Library/JavascriptArray.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2090,6 +2090,13 @@ namespace Js
20902090
// Code below has potential to throw due to OOM or SO. Just FailFast on those cases
20912091
AutoDisableInterrupt failFastError(scriptContext->GetThreadContext());
20922092

2093+
#if defined(TARGET_32)
2094+
if (fArray->head && (fArray->head->size >= SparseArraySegmentBase::INLINE_CHUNK_SIZE / shrinkFactor))
2095+
{
2096+
CopyHeadIfInlinedHeadSegment<double>(fArray, recycler);
2097+
}
2098+
#endif
2099+
20932100
for (seg = fArray->head; seg; seg = nextSeg)
20942101
{
20952102
nextSeg = seg->next;
@@ -5320,6 +5327,8 @@ namespace Js
53205327
AnalysisAssert(array->head);
53215328
SparseArraySegment<T>* newHeadSeg = array->ReallocNonLeafSegment((SparseArraySegment<T>*)PointerValue(array->head), array->head->next);
53225329
array->head = newHeadSeg;
5330+
array->InvalidateLastUsedSegment();
5331+
array->ClearSegmentMap();
53235332
}
53245333
}
53255334

lib/Runtime/Library/JavascriptArray.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,8 @@ namespace Js
549549
void SetHeadAndLastUsedSegment(SparseArraySegmentBase * segment);
550550
void SetLastUsedSegment(SparseArraySegmentBase * segment);
551551
bool HasSegmentMap() const;
552+
template<typename T>
553+
static void CopyHeadIfInlinedHeadSegment(JavascriptArray *array, Recycler *recycler);
552554

553555
private:
554556
void SetSegmentMap(SegmentBTreeRoot * segmentMap);
@@ -584,8 +586,6 @@ namespace Js
584586

585587
virtual int32 HeadSegmentIndexOfHelper(Var search, uint32 &fromIndex, uint32 toIndex, bool includesAlgorithm, ScriptContext * scriptContext);
586588

587-
template<typename T>
588-
static void CopyHeadIfInlinedHeadSegment(JavascriptArray *array, Recycler *recycler);
589589
template<typename T>
590590
static void ReallocateNonLeafLastSegmentIfLeaf(JavascriptArray * arr, Recycler * recycler);
591591

0 commit comments

Comments
 (0)