mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
accounts/abi: added dst.CanSet checks
This commit is contained in:
parent
3f6a41a22d
commit
1df389d5f7
1 changed files with 11 additions and 4 deletions
|
|
@ -17,6 +17,7 @@
|
|||
package abi
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"reflect"
|
||||
|
|
@ -110,9 +111,12 @@ func setSlice(dst, src reflect.Value) error {
|
|||
}
|
||||
}
|
||||
}
|
||||
if dst.CanSet() {
|
||||
dst.Set(slice)
|
||||
return nil
|
||||
}
|
||||
return errors.New("Cannot set slice, destination not settable")
|
||||
}
|
||||
|
||||
func setArray(dst, src reflect.Value) error {
|
||||
array := reflect.New(dst.Type()).Elem()
|
||||
|
|
@ -125,9 +129,12 @@ func setArray(dst, src reflect.Value) error {
|
|||
return err
|
||||
}
|
||||
}
|
||||
if dst.CanSet() {
|
||||
dst.Set(array)
|
||||
return nil
|
||||
}
|
||||
return errors.New("Cannot set array, destination not settable")
|
||||
}
|
||||
|
||||
func setStruct(dst, src reflect.Value) error {
|
||||
for i := 0; i < src.NumField(); i++ {
|
||||
|
|
|
|||
Loading…
Reference in a new issue