diff options
author | obscuren <geffobscura@gmail.com> | 2014-12-30 23:16:02 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-12-30 23:16:02 +0800 |
commit | 29c887ef2c39e91951e1ae14e7c4276334c434a4 (patch) | |
tree | 8659f74f018ee32ba8c278da19132a346045182e /vm/closure.go | |
parent | 9d429180f995f61e3448f9e0ffce713434590055 (diff) | |
download | dexon-29c887ef2c39e91951e1ae14e7c4276334c434a4.tar dexon-29c887ef2c39e91951e1ae14e7c4276334c434a4.tar.gz dexon-29c887ef2c39e91951e1ae14e7c4276334c434a4.tar.bz2 dexon-29c887ef2c39e91951e1ae14e7c4276334c434a4.tar.lz dexon-29c887ef2c39e91951e1ae14e7c4276334c434a4.tar.xz dexon-29c887ef2c39e91951e1ae14e7c4276334c434a4.tar.zst dexon-29c887ef2c39e91951e1ae14e7c4276334c434a4.zip |
Removed incorrect range check for push
Diffstat (limited to 'vm/closure.go')
-rw-r--r-- | vm/closure.go | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/vm/closure.go b/vm/closure.go index 97b31ada0..df216f2ae 100644 --- a/vm/closure.go +++ b/vm/closure.go @@ -1,8 +1,10 @@ package vm import ( + "math" "math/big" + "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/state" ) @@ -51,19 +53,14 @@ func (c *Closure) GetByte(x uint64) byte { } func (c *Closure) GetBytes(x, y int) []byte { - if x >= len(c.Code) || y >= len(c.Code) { - return nil - } - - return c.Code[x : x+y] + return c.GetRangeValue(uint64(x), uint64(y)) } -func (c *Closure) GetRangeValue(x, y uint64) []byte { - if x >= uint64(len(c.Code)) || y >= uint64(len(c.Code)) { - return nil - } +func (c *Closure) GetRangeValue(x, size uint64) []byte { + x = uint64(math.Min(float64(x), float64(len(c.Code)))) + y := uint64(math.Min(float64(x+size), float64(len(c.Code)))) - return c.Code[x : x+y] + return ethutil.LeftPadBytes(c.Code[x:y], int(size)) } func (c *Closure) Return(ret []byte) []byte { |