diff --git a/src/coreclr/gc/objecthandle.cpp b/src/coreclr/gc/objecthandle.cpp index af7805107e5909..41bdea86374d96 100644 --- a/src/coreclr/gc/objecthandle.cpp +++ b/src/coreclr/gc/objecthandle.cpp @@ -2089,7 +2089,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]) {