diff options
author | obscuren <geffobscura@gmail.com> | 2015-03-27 21:22:38 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-03-27 21:22:38 +0800 |
commit | 00f8319faf95e53333a9573fdc9e49df23238607 (patch) | |
tree | 224ce0c8f78f453e9cc283bba15905f6492cf90c | |
parent | eb102bf4bb0bff773824ff467fbb2e49c1f6939b (diff) | |
download | dexon-00f8319faf95e53333a9573fdc9e49df23238607.tar dexon-00f8319faf95e53333a9573fdc9e49df23238607.tar.gz dexon-00f8319faf95e53333a9573fdc9e49df23238607.tar.bz2 dexon-00f8319faf95e53333a9573fdc9e49df23238607.tar.lz dexon-00f8319faf95e53333a9573fdc9e49df23238607.tar.xz dexon-00f8319faf95e53333a9573fdc9e49df23238607.tar.zst dexon-00f8319faf95e53333a9573fdc9e49df23238607.zip |
Explicitly check memory's data store. #515
-rw-r--r-- | core/vm/memory.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/core/vm/memory.go b/core/vm/memory.go index dd47fa1b5..f5984d82f 100644 --- a/core/vm/memory.go +++ b/core/vm/memory.go @@ -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 |