diff --git a/src/coreclr/gc/objecthandle.cpp b/src/coreclr/gc/objecthandle.cpp index 45054e04941d8f..b57d3b18e60415 100644 --- a/src/coreclr/gc/objecthandle.cpp +++ b/src/coreclr/gc/objecthandle.cpp @@ -2001,7 +2001,8 @@ bool HandleTableBucket::Contains(OBJECTHANDLE handle) } HHANDLETABLE hTable = HndGetHandleTable(handle); - for (int uCPUindex=0; uCPUindex < g_theGCHeap->GetNumberOfHeaps(); uCPUindex++) + int n_slots = getNumberOfSlots(); + for (int uCPUindex=0; uCPUindex < n_slots; uCPUindex++) { if (hTable == this->pTable[uCPUindex]) {