From 25f696106c136140baaef2811f4a49fb2e39ca50 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Sat, 8 Aug 2009 10:34:04 +0200 Subject: [PATCH] valgrind memcheck: fix a b3g mem leak at shutdown. --- src/util-mpm-b3g.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/util-mpm-b3g.c b/src/util-mpm-b3g.c index acc180cb55..76b293e2fb 100644 --- a/src/util-mpm-b3g.c +++ b/src/util-mpm-b3g.c @@ -1003,6 +1003,19 @@ void B3gDestroyCtx(MpmCtx *mpm_ctx) { mpm_ctx->memory_cnt--; mpm_ctx->memory_size -= (sizeof(B3gHashItem) * ctx->scan_hash_size); } + if (ctx->scan_hash2) { + int h; + for (h = 0; h < ctx->scan_hash_size; h++) { + if (ctx->scan_hash2[h] == NULL) + continue; + + B3gHashFree(mpm_ctx, ctx->scan_hash2[h]); + } + + free(ctx->scan_hash2); + mpm_ctx->memory_cnt--; + mpm_ctx->memory_size -= (sizeof(B3gHashItem) * ctx->scan_hash_size); + } if (ctx->search_bloom) { int h; @@ -1035,6 +1048,19 @@ void B3gDestroyCtx(MpmCtx *mpm_ctx) { mpm_ctx->memory_cnt--; mpm_ctx->memory_size -= (sizeof(B3gHashItem) * ctx->search_hash_size); } + if (ctx->search_hash2) { + int h; + for (h = 0; h < ctx->search_hash_size; h++) { + if (ctx->search_hash2[h] == NULL) + continue; + + B3gHashFree(mpm_ctx, ctx->search_hash2[h]); + } + + free(ctx->search_hash2); + mpm_ctx->memory_cnt--; + mpm_ctx->memory_size -= (sizeof(B3gHashItem) * ctx->search_hash_size); + } if (ctx->scan_pminlen) { free(ctx->scan_pminlen);