From c71ae9b31034641a31c34b46e3f18c58e37f531f Mon Sep 17 00:00:00 2001 From: DarthVader <61409963+darsvador@users.noreply.github.com> Date: Tue, 16 Mar 2021 19:07:32 +0800 Subject: [PATCH] Fix: core panics when zero domain/full type of rule (#786) --- common/strmatcher/mph_matcher.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/strmatcher/mph_matcher.go b/common/strmatcher/mph_matcher.go index 794d6b8d4..21b98e764 100644 --- a/common/strmatcher/mph_matcher.go +++ b/common/strmatcher/mph_matcher.go @@ -94,6 +94,10 @@ func (g *MphMatcherGroup) Build() { g.ac.Build() } keyLen := len(*g.ruleMap) + if keyLen == 0 { + keyLen = 1 + (*g.ruleMap)["empty___"] = RollingHash("empty___") + } g.level0 = make([]uint32, nextPow2(keyLen/4)) g.level0Mask = len(g.level0) - 1 g.level1 = make([]uint32, nextPow2(keyLen))