diff --git a/core/vm/memory.go b/core/vm/memory.go index 69c709531e..54bc2b2849 100644 --- a/core/vm/memory.go +++ b/core/vm/memory.go @@ -77,13 +77,13 @@ func (m *Memory) Set32(offset uint64, val *uint256.Int) { val.PutUint256(m.store[offset:]) } -// Resize resizes the memory to size +// Resize grows the memory to the requested size. func (m *Memory) Resize(size uint64) { - if uint64(m.Len()) < size { - if uint64(cap(m.store)) > size { + if uint64(len(m.store)) < size { + if uint64(cap(m.store)) >= size { m.store = m.store[:size] } else { - m.store = append(m.store, make([]byte, size-uint64(m.Len()))...) + m.store = append(m.store, make([]byte, size-uint64(len(m.store)))...) } } }