aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-06-20 03:41:37 +0800
committerobscuren <geffobscura@gmail.com>2014-06-20 03:41:37 +0800
commit933aa63b7d302cff4287ba2814f3bd0f7744ed8e (patch)
treec4c0577ef502a0fc807867cb8858069c9a3ef35d /ethchain
parent80ffe1610c87bc56f625797a4f839a931af70558 (diff)
downloadgo-tangerine-933aa63b7d302cff4287ba2814f3bd0f7744ed8e.tar
go-tangerine-933aa63b7d302cff4287ba2814f3bd0f7744ed8e.tar.gz
go-tangerine-933aa63b7d302cff4287ba2814f3bd0f7744ed8e.tar.bz2
go-tangerine-933aa63b7d302cff4287ba2814f3bd0f7744ed8e.tar.lz
go-tangerine-933aa63b7d302cff4287ba2814f3bd0f7744ed8e.tar.xz
go-tangerine-933aa63b7d302cff4287ba2814f3bd0f7744ed8e.tar.zst
go-tangerine-933aa63b7d302cff4287ba2814f3bd0f7744ed8e.zip
Length check on get
Diffstat (limited to 'ethchain')
-rw-r--r--ethchain/stack.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/ethchain/stack.go b/ethchain/stack.go
index 37d1f84b9..a9fa2e522 100644
--- a/ethchain/stack.go
+++ b/ethchain/stack.go
@@ -2,7 +2,7 @@ package ethchain
import (
"fmt"
- _ "github.com/ethereum/eth-go/ethutil"
+ "math"
"math/big"
)
@@ -118,7 +118,13 @@ func (m *Memory) Resize(size uint64) {
}
func (m *Memory) Get(offset, size int64) []byte {
- return m.store[offset : offset+size]
+ if len(m.store) > int(offset) {
+ end := int(math.Min(float64(len(m.store)), float64(offset+size)))
+
+ return m.store[offset:end]
+ }
+
+ return nil
}
func (m *Memory) Len() int {