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
This commit is contained in:
committed by
Péter Szilágyi
parent
cf5d4b5541
commit
23c6fcdbe8
@ -46,7 +46,7 @@ func (i *Interface) SetBool(b bool) { i.object = &b }
|
||||
func (i *Interface) SetBools(bs []bool) { i.object = &bs }
|
||||
func (i *Interface) SetString(str string) { i.object = &str }
|
||||
func (i *Interface) SetStrings(strs *Strings) { i.object = &strs.strs }
|
||||
func (i *Interface) SetBinary(binary []byte) { i.object = &binary }
|
||||
func (i *Interface) SetBinary(binary []byte) { b := common.CopyBytes(binary); i.object = &b }
|
||||
func (i *Interface) SetBinaries(binaries [][]byte) { i.object = &binaries }
|
||||
func (i *Interface) SetAddress(address *Address) { i.object = &address.address }
|
||||
func (i *Interface) SetAddresses(addrs *Addresses) { i.object = &addrs.addresses }
|
||||
|
Reference in New Issue
Block a user