diff --git a/src/util-mpm-ac-bs.c b/src/util-mpm-ac-bs.c index 9e08a2344c..60608ab9fb 100644 --- a/src/util-mpm-ac-bs.c +++ b/src/util-mpm-ac-bs.c @@ -192,7 +192,7 @@ static inline SCACBSPattern *SCACBSInitHashLookup(SCACBSCtx *ctx, uint8_t *pat, { uint32_t hash = SCACBSInitHashRaw(pat, patlen); - if (ctx->init_hash[hash] == NULL) { + if (ctx->init_hash == NULL || ctx->init_hash[hash] == NULL) { return NULL; } @@ -293,6 +293,10 @@ static inline int SCACBSInitHashAdd(SCACBSCtx *ctx, SCACBSPattern *p) { uint32_t hash = SCACBSInitHash(p); + if (ctx->init_hash == NULL) { + return 0; + } + if (ctx->init_hash[hash] == NULL) { ctx->init_hash[hash] = p; return 0; @@ -1162,7 +1166,7 @@ int SCACBSPreparePatterns(MpmCtx *mpm_ctx) { SCACBSCtx *ctx = (SCACBSCtx *)mpm_ctx->ctx; - if (mpm_ctx->pattern_cnt == 0) { + if (mpm_ctx->pattern_cnt == 0 || ctx->init_hash == NULL) { SCLogDebug("no patterns supplied to this mpm_ctx"); return 0; } diff --git a/src/util-mpm-ac-gfbs.c b/src/util-mpm-ac-gfbs.c index f26d7c82cc..885a66c2e9 100644 --- a/src/util-mpm-ac-gfbs.c +++ b/src/util-mpm-ac-gfbs.c @@ -186,7 +186,7 @@ static inline SCACGfbsPattern *SCACGfbsInitHashLookup(SCACGfbsCtx *ctx, uint8_t { uint32_t hash = SCACGfbsInitHashRaw(pat, patlen); - if (ctx->init_hash[hash] == NULL) { + if (ctx->init_hash == NULL || ctx->init_hash[hash] == NULL) { return NULL; } @@ -287,6 +287,10 @@ static inline int SCACGfbsInitHashAdd(SCACGfbsCtx *ctx, SCACGfbsPattern *p) { uint32_t hash = SCACGfbsInitHash(p); + if (ctx->init_hash == NULL) { + return 0; + } + if (ctx->init_hash[hash] == NULL) { ctx->init_hash[hash] = p; return 0; @@ -1036,7 +1040,7 @@ int SCACGfbsPreparePatterns(MpmCtx *mpm_ctx) { SCACGfbsCtx *ctx = (SCACGfbsCtx *)mpm_ctx->ctx; - if (mpm_ctx->pattern_cnt == 0) { + if (mpm_ctx->pattern_cnt == 0 || ctx->init_hash == NULL) { SCLogDebug("No patterns supplied to this mpm_ctx"); return 0; } diff --git a/src/util-mpm-ac.c b/src/util-mpm-ac.c index e64aff95d0..dc520f1124 100644 --- a/src/util-mpm-ac.c +++ b/src/util-mpm-ac.c @@ -192,7 +192,7 @@ static inline SCACPattern *SCACInitHashLookup(SCACCtx *ctx, uint8_t *pat, { uint32_t hash = SCACInitHashRaw(pat, patlen); - if (ctx->init_hash[hash] == NULL) { + if (ctx->init_hash == NULL || ctx->init_hash[hash] == NULL) { return NULL; } @@ -293,6 +293,10 @@ static inline int SCACInitHashAdd(SCACCtx *ctx, SCACPattern *p) { uint32_t hash = SCACInitHash(p); + if (ctx->init_hash == NULL) { + return 0; + } + if (ctx->init_hash[hash] == NULL) { ctx->init_hash[hash] = p; return 0; @@ -953,7 +957,7 @@ int SCACPreparePatterns(MpmCtx *mpm_ctx) { SCACCtx *ctx = (SCACCtx *)mpm_ctx->ctx; - if (mpm_ctx->pattern_cnt == 0) { + if (mpm_ctx->pattern_cnt == 0 || ctx->init_hash == NULL) { SCLogDebug("no patterns supplied to this mpm_ctx"); return 0; }