diff options
author | obscuren <geffobscura@gmail.com> | 2014-11-14 20:47:12 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-11-14 20:47:12 +0800 |
commit | f6e55962a8cadfb440dd03467017941b96838362 (patch) | |
tree | 259bdf39e8697f03c0f1944d4c33cbfb21277204 /vm/stack.go | |
parent | 20d518ee959f1621a5accf1f3432282a6c0d6c3c (diff) | |
download | go-tangerine-f6e55962a8cadfb440dd03467017941b96838362.tar.gz go-tangerine-f6e55962a8cadfb440dd03467017941b96838362.tar.zst go-tangerine-f6e55962a8cadfb440dd03467017941b96838362.zip |
Fixes for PV41/42
* Don't expand mem on empty value
* Removed all coinbase logs for PV42
* Removed C++ bug stuff for LOG*
Diffstat (limited to 'vm/stack.go')
-rw-r--r-- | vm/stack.go | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/vm/stack.go b/vm/stack.go index 69ded6562..2eca60ad1 100644 --- a/vm/stack.go +++ b/vm/stack.go @@ -107,20 +107,26 @@ type Memory struct { store []byte } +func NewMemory() *Memory { + return &Memory{nil} +} + func (m *Memory) Set(offset, size int64, value []byte) { - totSize := offset + size - lenSize := int64(len(m.store) - 1) - if totSize > lenSize { - // Calculate the diff between the sizes - diff := totSize - lenSize - if diff > 0 { - // Create a new empty slice and append it - newSlice := make([]byte, diff-1) - // Resize slice - m.store = append(m.store, newSlice...) + if len(value) > 0 { + totSize := offset + size + lenSize := int64(len(m.store) - 1) + if totSize > lenSize { + // Calculate the diff between the sizes + diff := totSize - lenSize + if diff > 0 { + // Create a new empty slice and append it + newSlice := make([]byte, diff-1) + // Resize slice + m.store = append(m.store, newSlice...) + } } + copy(m.store[offset:offset+size], value) } - copy(m.store[offset:offset+size], value) } func (m *Memory) Resize(size uint64) { |