diff options
author | Elias Naur <elias.naur@gmail.com> | 2017-07-17 20:25:46 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-07-17 20:25:46 +0800 |
commit | 23c6fcdbe834b70ff25473e6ff03da94814609c1 (patch) | |
tree | 09eaf858707d61ff2f117cadc0e11e2a0e77f0da /mobile/big.go | |
parent | cf5d4b55412f570bd1b492998b0c0b8e953e2418 (diff) | |
download | dexon-23c6fcdbe834b70ff25473e6ff03da94814609c1.tar dexon-23c6fcdbe834b70ff25473e6ff03da94814609c1.tar.gz dexon-23c6fcdbe834b70ff25473e6ff03da94814609c1.tar.bz2 dexon-23c6fcdbe834b70ff25473e6ff03da94814609c1.tar.lz dexon-23c6fcdbe834b70ff25473e6ff03da94814609c1.tar.xz dexon-23c6fcdbe834b70ff25473e6ff03da94814609c1.tar.zst dexon-23c6fcdbe834b70ff25473e6ff03da94814609c1.zip |
mobile: don't retain transient []byte in CallMsg.SetData (#14804)
* mobile: don't retain transient []byte in CallMsg.SetData
Go mobile doesn't copy []byte parameters, for performance and to allow
writes to the byte array be reflected in the native byte array.
Unfortunately, that means []byte arguments are only valid during the
call it is being passed into.
CallMsg.SetData retains such a byte array. Copy it instead
Fixes #14675
* mobile: copy all []byte arguments from gomobile
To avoid subtle errors when accidentially retaining an otherwise
transient byte slice coming from gomobile, copy all byte slices before
use.
* mobile: replace copySlice with common.CopyBytes
Diffstat (limited to 'mobile/big.go')
-rw-r--r-- | mobile/big.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/mobile/big.go b/mobile/big.go index 525717caa..564fbad47 100644 --- a/mobile/big.go +++ b/mobile/big.go @@ -21,6 +21,8 @@ package geth import ( "errors" "math/big" + + "github.com/ethereum/go-ethereum/common" ) // A BigInt represents a signed multi-precision integer. @@ -52,7 +54,7 @@ func (bi *BigInt) GetInt64() int64 { // SetBytes interprets buf as the bytes of a big-endian unsigned integer and sets // the big int to that value. func (bi *BigInt) SetBytes(buf []byte) { - bi.bigint.SetBytes(buf) + bi.bigint.SetBytes(common.CopyBytes(buf)) } // SetInt64 sets the big int to x. |