aboutsummaryrefslogtreecommitdiffstats
path: root/vm
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-19 22:07:47 +0800
committerobscuren <geffobscura@gmail.com>2015-03-19 22:07:47 +0800
commit797bbce15ecf9ec76f6375a328c63eb9abcc3b5a (patch)
tree340c6b214ef888cd06ef5a7d87b1c9319bf2772f /vm
parentad7e4912146d0bfe9907a11d5e302db3143e156e (diff)
parenta756dbeb7b1027eb91130ecf8d5440dca8e738d8 (diff)
downloadgo-tangerine-797bbce15ecf9ec76f6375a328c63eb9abcc3b5a.tar.gz
go-tangerine-797bbce15ecf9ec76f6375a328c63eb9abcc3b5a.tar.zst
go-tangerine-797bbce15ecf9ec76f6375a328c63eb9abcc3b5a.zip
Merge branch 'develop' into conversion
Diffstat (limited to 'vm')
-rw-r--r--vm/vm.go28
1 files changed, 18 insertions, 10 deletions
diff --git a/vm/vm.go b/vm/vm.go
index 3bfaef271..123da6b03 100644
--- a/vm/vm.go
+++ b/vm/vm.go
@@ -441,13 +441,16 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
self.Printf(" => %d", l)
case CALLDATACOPY:
var (
- mOff = stack.pop().Uint64()
- cOff = stack.pop().Uint64()
- l = stack.pop().Uint64()
+ mOff = stack.pop()
+ cOff = stack.pop()
+ l = stack.pop()
)
- data := getData(callData, cOff, l)
+ var data []byte
+ if cOff.Cmp(big.NewInt(int64(len(callData)))) <= 0 {
+ data = getData(callData, cOff.Uint64(), l.Uint64())
+ }
- mem.Set(mOff, l, data)
+ mem.Set(mOff.Uint64(), l.Uint64(), data)
self.Printf(" => [%v, %v, %v] %x", mOff, cOff, l, data)
case CODESIZE, EXTCODESIZE:
@@ -472,14 +475,19 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
} else {
code = context.Code
}
+
var (
- mOff = stack.pop().Uint64()
- cOff = stack.pop().Uint64()
- l = stack.pop().Uint64()
+ mOff = stack.pop()
+ cOff = stack.pop()
+ l = stack.pop()
)
- codeCopy := getData(code, cOff, l)
- mem.Set(mOff, l, codeCopy)
+ var codeCopy []byte
+ if cOff.Cmp(big.NewInt(int64(len(code)))) <= 0 {
+ codeCopy = getData(code, cOff.Uint64(), l.Uint64())
+ }
+
+ mem.Set(mOff.Uint64(), l.Uint64(), codeCopy)
self.Printf(" => [%v, %v, %v] %x", mOff, cOff, l, codeCopy)
case GASPRICE: