Skip to content

Commit 0819bca

Browse files
Merge pull request #207 from AlasdairBennett/dtrie-get-panic
Add nil check to Dtrie.Get()
2 parents 97fa74f + 6669135 commit 0819bca

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

trie/dtrie/dtrie.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ func (d *Dtrie) Size() (size int) {
8080
// Get returns the value for the associated key or returns nil if the
8181
// key does not exist.
8282
func (d *Dtrie) Get(key interface{}) interface{} {
83-
return get(d.root, d.hasher(key), key).Value()
83+
node := get(d.root, d.hasher(key), key)
84+
if node != nil {
85+
return node.Value()
86+
}
87+
return nil
8488
}
8589

8690
// Insert adds a key value pair to the Dtrie, replacing the existing value if

0 commit comments

Comments
 (0)