From b7bfbc1e649cecc9fa11ad55b3943272a919c24b Mon Sep 17 00:00:00 2001 From: Darioush Jalali Date: Fri, 17 Mar 2023 03:19:51 -0700 Subject: [PATCH] trie, accounts/abi: add error-checks (#26914) --- accounts/abi/abi.go | 5 ++++- trie/stacktrie.go | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/accounts/abi/abi.go b/accounts/abi/abi.go index 841d3c6cb676..62b860e18c77 100644 --- a/accounts/abi/abi.go +++ b/accounts/abi/abi.go @@ -246,7 +246,10 @@ func UnpackRevert(data []byte) (string, error) { if !bytes.Equal(data[:4], revertSelector) { return "", errors.New("invalid data for unpacking") } - typ, _ := NewType("string", "", nil) + typ, err := NewType("string", "", nil) + if err != nil { + return "", err + } unpacked, err := (Arguments{{Type: typ}}).Unpack(data[4:]) if err != nil { return "", err diff --git a/trie/stacktrie.go b/trie/stacktrie.go index e7b3171af6e8..83034e29a530 100644 --- a/trie/stacktrie.go +++ b/trie/stacktrie.go @@ -144,7 +144,9 @@ func (st *StackTrie) unmarshalBinary(r io.Reader) error { Val []byte Key []byte } - gob.NewDecoder(r).Decode(&dec) + if err := gob.NewDecoder(r).Decode(&dec); err != nil { + return err + } st.owner = dec.Owner st.nodeType = dec.NodeType st.val = dec.Val @@ -158,7 +160,9 @@ func (st *StackTrie) unmarshalBinary(r io.Reader) error { continue } var child StackTrie - child.unmarshalBinary(r) + if err := child.unmarshalBinary(r); err != nil { + return err + } st.children[i] = &child } return nil