Don't panic on zero-length token from misformed subject

This commit is contained in:
Derek Collison
2013-08-13 23:46:15 -04:00
parent e391e6f696
commit 9fcb264534
2 changed files with 10 additions and 1 deletions

View File

@@ -290,7 +290,7 @@ func (s *Sublist) Remove(subject []byte, sub interface{}) {
levels := lnts[:0]
for _, t := range toks {
if l == nil {
if l == nil || len(t) == 0 {
s.mu.Unlock()
return
}

View File

@@ -357,6 +357,15 @@ func TestResultSetSnapshots(t *testing.T) {
verifyLen(r, 1, t)
}
func TestBadSubjectOnRemove(t *testing.T) {
bad := []byte("a.b..d")
value := "bad"
s := New()
s.Insert(bad, value)
s.Remove(bad, value)
}
// -- Benchmarks Setup --
var subs [][]byte