Skip to content

Commit e921df7

Browse files
committed
Avoid UB
1 parent e339bf3 commit e921df7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/coreclr/interpreter/stackmap.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,8 @@ void InterpreterStackMap::PopulateStackMap(ICorJitInfo* jitInfo, CORINFO_CLASS_H
7979
}
8080

8181
// Shrink our allocation based on the number of slots we actually recorded
82-
m_slots = (InterpreterStackMapSlot *)realloc(m_slots, sizeof(InterpreterStackMapSlot) * m_slotCount);
82+
unsigned finalSize = sizeof(InterpreterStackMapSlot) * m_slotCount;
83+
if (finalSize == 0)
84+
finalSize = sizeof(InterpreterStackMapSlot);
85+
m_slots = (InterpreterStackMapSlot *)realloc(m_slots, finalSize);
8386
}

0 commit comments

Comments
 (0)