Skip to content

Commit

Permalink
Explicitly check memory's data store. #515
Browse files Browse the repository at this point in the history
  • Loading branch information
obscuren committed Mar 27, 2015
1 parent eb102bf commit 00f8319
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion core/vm/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@ func NewMemory() *Memory {
}

func (m *Memory) Set(offset, size uint64, value []byte) {
// If the length of the store is 0 this is a complete failure
// memory size is set prior to calling this method so enough size
// should always be available.
if len(m.store) == 0 {
panic("INVALID memory: store empty")
}

value = common.RightPadBytes(value, int(size))

totSize := offset + size
lenSize := uint64(len(m.store) - 1)
lenSize := int64(len(m.store) - 1)
if totSize > lenSize {
// Calculate the diff between the sizes
diff := totSize - lenSize
Expand Down

0 comments on commit 00f8319

Please sign in to comment.