Skip to content

Commit

Permalink
Merge pull request #207 from AlasdairBennett/dtrie-get-panic
Browse files Browse the repository at this point in the history
Add nil check to Dtrie.Get()
  • Loading branch information
brianshannan-wf committed Mar 9, 2020
2 parents 97fa74f + 6669135 commit 0819bca
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion trie/dtrie/dtrie.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ func (d *Dtrie) Size() (size int) {
// Get returns the value for the associated key or returns nil if the
// key does not exist.
func (d *Dtrie) Get(key interface{}) interface{} {
return get(d.root, d.hasher(key), key).Value()
node := get(d.root, d.hasher(key), key)
if node != nil {
return node.Value()
}
return nil
}

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

0 comments on commit 0819bca

Please sign in to comment.