From 23c6fcdbe834b70ff25473e6ff03da94814609c1 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Mon, 17 Jul 2017 14:25:46 +0200 Subject: 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 --- mobile/ethereum.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mobile/ethereum.go') diff --git a/mobile/ethereum.go b/mobile/ethereum.go index 30a94dc89..c9bb3013c 100644 --- a/mobile/ethereum.go +++ b/mobile/ethereum.go @@ -64,7 +64,7 @@ func (msg *CallMsg) SetFrom(address *Address) { msg.msg.From = address.address func (msg *CallMsg) SetGas(gas int64) { msg.msg.Gas = big.NewInt(gas) } func (msg *CallMsg) SetGasPrice(price *BigInt) { msg.msg.GasPrice = price.bigint } func (msg *CallMsg) SetValue(value *BigInt) { msg.msg.Value = value.bigint } -func (msg *CallMsg) SetData(data []byte) { msg.msg.Data = data } +func (msg *CallMsg) SetData(data []byte) { msg.msg.Data = common.CopyBytes(data) } func (msg *CallMsg) SetTo(address *Address) { if address == nil { msg.msg.To = nil -- cgit