Skip to content

Commit 7464f0a

Browse files
authored
trie: better error-handling ethereum#23657 (XinFinOrg#1073)
1 parent 655f975 commit 7464f0a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

trie/trie.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ func (t *Trie) TryGetNode(path []byte) ([]byte, int, error) {
166166
}
167167

168168
func (t *Trie) tryGetNode(origNode node, path []byte, pos int) (item []byte, newnode node, resolved int, err error) {
169+
// If non-existent path requested, abort
170+
if origNode == nil {
171+
return nil, nil, 0, nil
172+
}
169173
// If we reached the requested path, return the current node
170174
if pos >= len(path) {
171175
// Although we most probably have the original node expanded, encoding
@@ -185,10 +189,6 @@ func (t *Trie) tryGetNode(origNode node, path []byte, pos int) (item []byte, new
185189
}
186190
// Path still needs to be traversed, descend into children
187191
switch n := (origNode).(type) {
188-
case nil:
189-
// Non-existent path requested, abort
190-
return nil, nil, 0, nil
191-
192192
case valueNode:
193193
// Path prematurely ended, abort
194194
return nil, nil, 0, nil

0 commit comments

Comments
 (0)