Browse Source

Fix: core panics when zero domain/full type of rule (#786)

DarthVader 4 years ago
parent
commit
c71ae9b310
1 changed files with 4 additions and 0 deletions
  1. 4 0
      common/strmatcher/mph_matcher.go

+ 4 - 0
common/strmatcher/mph_matcher.go

@@ -94,6 +94,10 @@ func (g *MphMatcherGroup) Build() {
 		g.ac.Build()
 		g.ac.Build()
 	}
 	}
 	keyLen := len(*g.ruleMap)
 	keyLen := len(*g.ruleMap)
+	if keyLen == 0 {
+		keyLen = 1
+		(*g.ruleMap)["empty___"] = RollingHash("empty___")
+	}
 	g.level0 = make([]uint32, nextPow2(keyLen/4))
 	g.level0 = make([]uint32, nextPow2(keyLen/4))
 	g.level0Mask = len(g.level0) - 1
 	g.level0Mask = len(g.level0) - 1
 	g.level1 = make([]uint32, nextPow2(keyLen))
 	g.level1 = make([]uint32, nextPow2(keyLen))