diff --git a/math/int.go b/math/int.go index 4c1e9ceb849..159e2d7d224 100644 --- a/math/int.go +++ b/math/int.go @@ -383,8 +383,8 @@ func (i *Int) MarshalTo(data []byte) (n int, err error) { i.i = new(big.Int) } if i.i.BitLen() == 0 { // The value 0 - copy(data, []byte{0x30}) - return 1, nil + n = copy(data, []byte{0x30}) + return n, nil } bz, err := i.Marshal() @@ -392,8 +392,8 @@ func (i *Int) MarshalTo(data []byte) (n int, err error) { return 0, err } - copy(data, bz) - return len(bz), nil + n = copy(data, bz) + return n, nil } // Unmarshal implements the gogo proto custom type interface. diff --git a/math/uint.go b/math/uint.go index 02efb9fc8dc..8ce6105e9fb 100644 --- a/math/uint.go +++ b/math/uint.go @@ -162,8 +162,8 @@ func (u *Uint) MarshalTo(data []byte) (n int, err error) { u.i = new(big.Int) } if u.i.BitLen() == 0 { // The value 0 - copy(data, []byte{0x30}) - return 1, nil + n = copy(data, []byte{0x30}) + return n, nil } bz, err := u.Marshal() @@ -171,8 +171,8 @@ func (u *Uint) MarshalTo(data []byte) (n int, err error) { return 0, err } - copy(data, bz) - return len(bz), nil + n = copy(data, bz) + return n, nil } // Unmarshal implements the gogo proto custom type interface.