Skip to content

Commit d160d49

Browse files
committed
[MERGE #2198 @rajatd] Keep property records live on IteratorObjectEnumerator
Merge pull request #2198 from rajatd:iteratorEnum We need to keep property records for properties being enumerated live during enumeration. For dynamic objects, type handlers hold references to property records and for non-existent properties, we have code in ForInObjectEnumerator::MoveAndGetNext to keep the new records live. Taking care of this case for Proxies which use IteratorObjectEnumerator
2 parents bc52eb0 + 4f58ae9 commit d160d49

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/Runtime/Library/IteratorObjectEnumerator.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ namespace Js
4545
{
4646
JavascriptString* propertyName = JavascriptConversion::ToString(currentIndex, scriptContext);
4747
GetScriptContext()->GetOrAddPropertyRecord(propertyName->GetString(), propertyName->GetLength(), &propertyRecord);
48+
49+
// Need to keep property records alive during enumeration to prevent collection
50+
// and eventual reuse during the same enumeration. For DynamicObjects, property
51+
// records are kept alive by type handlers.
52+
this->propertyRecords.Prepend(iteratorObject->GetRecycler(), propertyRecord);
4853
}
4954

5055
propertyId = propertyRecord->GetPropertyId();

lib/Runtime/Library/IteratorObjectEnumerator.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace Js
2121
RecyclableObject* iteratorObject;
2222
Var value;
2323
BOOL done;
24+
SListBase<Js::PropertyRecord const *> propertyRecords;
2425
};
2526

2627
}

0 commit comments

Comments
 (0)