Fix: domain trie crash if not match in #758 (#762)

This commit is contained in:
gVisor bot 2020-06-24 19:46:37 +08:00
parent 806047488a
commit ff73876477
2 changed files with 2 additions and 1 deletions

View file

@ -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
}

View file

@ -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) {