Fix index out of range in patricia tree

Bug #32 reported that there is an index out of range error. This
issue was introduced in 703b087.

Fix #32 and add a test to detect this issue
This commit is contained in:
Soheil Hassas Yeganeh
2016-07-15 08:07:12 -07:00
parent e85da3027e
commit eddb3b1467
2 changed files with 12 additions and 1 deletions

View File

@@ -161,6 +161,10 @@ func (n *ptNode) match(b []byte, prefix bool) bool {
return true
}
if l >= len(b) {
return false
}
nextN, ok := n.next[b[l]]
if !ok {
return false