mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 01:13:45 +00:00
accounts/abi: count array fields after unpacking
In current codebase array fields are counted before unpacking output. So, if we have array with 2 fields: toGoType function will try to unpack values from 64 till 64 + 2*32 which is not correct in my opinion. I shifted counting to be done after processing array, so in case array is the first field, and it has 2 elements: we will read it from 0 till 2*32. Additionally array doesnt require length prefix, so field that follows array should be read from 64 byte. This is why i made additional substitution in this change.
This commit is contained in:
parent
a16d68e126
commit
7ed09ed0bc
1 changed files with 4 additions and 3 deletions
|
|
@ -71,14 +71,15 @@ func (e Event) tupleUnpack(v interface{}, output []byte) error {
|
|||
if input.Indexed {
|
||||
// can't read, continue
|
||||
continue
|
||||
} else if input.Type.T == ArrayTy {
|
||||
// need to move this up because they read sequentially
|
||||
j += input.Type.Size
|
||||
}
|
||||
marshalledValue, err := toGoType((i+j)*32, input.Type, output)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if input.Type.T == ArrayTy {
|
||||
// need to move this up because they read sequentially
|
||||
j += input.Type.Size - 1
|
||||
}
|
||||
reflectValue := reflect.ValueOf(marshalledValue)
|
||||
|
||||
switch value.Kind() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue