Skip to content

Commit

Permalink
Fix: domain trie crash if not match in #758 (#762)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kr328 authored Jun 24, 2020
1 parent 3dfff84 commit 14c9cf1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion component/trie/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (t *DomainTrie) Search(domain string) *Node {

n := t.search(t.root, parts)

if n.Data == nil {
if n == nil || n.Data == nil {
return nil
}

Expand Down
1 change: 1 addition & 0 deletions component/trie/domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func TestTrie_Basic(t *testing.T) {
assert.NotNil(t, tree.Insert("", localIP))
assert.Nil(t, tree.Search(""))
assert.NotNil(t, tree.Search("localhost"))
assert.Nil(t, tree.Search("www.google.com"))
}

func TestTrie_Wildcard(t *testing.T) {
Expand Down

0 comments on commit 14c9cf1

Please sign in to comment.