diff options
author | Felix Lange <fjl@twurst.com> | 2015-03-19 22:21:49 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-03-19 22:21:49 +0800 |
commit | ce063e8d9c2d26dd283a43b097903628225179ea (patch) | |
tree | 3bf88d349fd799285d75926f4486cb13f3cc7c70 /vm/vm.go | |
parent | e80dda605130479086bed363e395a102a89a574a (diff) | |
parent | 797bbce15ecf9ec76f6375a328c63eb9abcc3b5a (diff) | |
download | go-tangerine-ce063e8d9c2d26dd283a43b097903628225179ea.tar go-tangerine-ce063e8d9c2d26dd283a43b097903628225179ea.tar.gz go-tangerine-ce063e8d9c2d26dd283a43b097903628225179ea.tar.bz2 go-tangerine-ce063e8d9c2d26dd283a43b097903628225179ea.tar.lz go-tangerine-ce063e8d9c2d26dd283a43b097903628225179ea.tar.xz go-tangerine-ce063e8d9c2d26dd283a43b097903628225179ea.tar.zst go-tangerine-ce063e8d9c2d26dd283a43b097903628225179ea.zip |
Merge remote-tracking branch 'ethereum/conversion' into conversion
Diffstat (limited to 'vm/vm.go')
-rw-r--r-- | vm/vm.go | 37 |
1 files changed, 18 insertions, 19 deletions
@@ -441,24 +441,18 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) { self.Printf(" => %d", l) case CALLDATACOPY: var ( - size = uint64(len(callData)) - mOff = stack.pop().Uint64() - cOff = stack.pop().Uint64() - l = stack.pop().Uint64() + mOff = stack.pop() + cOff = stack.pop() + l = stack.pop() ) - - if cOff > size { - cOff = 0 - l = 0 - } else if cOff+l > size { - l = 0 + var data []byte + if cOff.Cmp(big.NewInt(int64(len(callData)))) <= 0 { + data = getData(callData, cOff.Uint64(), l.Uint64()) } - code := callData[cOff : cOff+l] - - mem.Set(mOff, l, code) + mem.Set(mOff.Uint64(), l.Uint64(), data) - self.Printf(" => [%v, %v, %v] %x", mOff, cOff, l, callData[cOff:cOff+l]) + self.Printf(" => [%v, %v, %v] %x", mOff, cOff, l, data) case CODESIZE, EXTCODESIZE: var code []byte if op == EXTCODESIZE { @@ -481,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 := getCode(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: |