Skip to content

Commit 394e24f

Browse files
authored
Ensure MetadataEnumResult is sufficiently updated by MetaDataImport::Enum (#56756)
`MetadataEnumResult` has a fixed inline buffer for returning small results and a pointer to allow it to return larger ones. The indexer for this checks the pointer and if non-null assumes that's the current set of values. But if a `MetadataEnumResult` is re-used within a loop, values written to it by `MetaDataImport::Enum` may bleed from one loop iteration to the next if the iterations first get a large result and then a small one. One case where this could happen was in libraries PGO tests, where PGO data encouraged the jit to inline `MemberInfoCache<T>.PopulateProperties(Filter,...)` into `MemberInfoCache<T>.PopulateProperties(Filter)`. Note this also is a conseqeunce of skipping zero init locals; without that the struct would have been zeroed each loop iteration. Fixes #56655.
1 parent 0ea6d0c commit 394e24f

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/coreclr/vm/managedmdimport.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ static int * EnsureResultSize(MetadataEnumResult * pResult, ULONG length)
163163
else
164164
{
165165
ZeroMemory(pResult->smallResult, sizeof(pResult->smallResult));
166+
pResult->largeResult = NULL;
166167
p = pResult->smallResult;
167168
}
168169

0 commit comments

Comments
 (0)