Skip to content

Commit b7bfbc1

Browse files
author
Darioush Jalali
authored
trie, accounts/abi: add error-checks (#26914)
1 parent f733657 commit b7bfbc1

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

accounts/abi/abi.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,10 @@ func UnpackRevert(data []byte) (string, error) {
246246
if !bytes.Equal(data[:4], revertSelector) {
247247
return "", errors.New("invalid data for unpacking")
248248
}
249-
typ, _ := NewType("string", "", nil)
249+
typ, err := NewType("string", "", nil)
250+
if err != nil {
251+
return "", err
252+
}
250253
unpacked, err := (Arguments{{Type: typ}}).Unpack(data[4:])
251254
if err != nil {
252255
return "", err

trie/stacktrie.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ func (st *StackTrie) unmarshalBinary(r io.Reader) error {
144144
Val []byte
145145
Key []byte
146146
}
147-
gob.NewDecoder(r).Decode(&dec)
147+
if err := gob.NewDecoder(r).Decode(&dec); err != nil {
148+
return err
149+
}
148150
st.owner = dec.Owner
149151
st.nodeType = dec.NodeType
150152
st.val = dec.Val
@@ -158,7 +160,9 @@ func (st *StackTrie) unmarshalBinary(r io.Reader) error {
158160
continue
159161
}
160162
var child StackTrie
161-
child.unmarshalBinary(r)
163+
if err := child.unmarshalBinary(r); err != nil {
164+
return err
165+
}
162166
st.children[i] = &child
163167
}
164168
return nil

0 commit comments

Comments
 (0)