From b51075e804189a50191581611fa5e21e57ae602f Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Thu, 5 Mar 2015 13:00:33 +0100 Subject: [PATCH] detect: remove config at prefix Remove config at prefix when freeing a detect engine. --- src/detect-engine.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/detect-engine.c b/src/detect-engine.c index 688c419615..df728ed059 100644 --- a/src/detect-engine.c +++ b/src/detect-engine.c @@ -761,7 +761,10 @@ DetectEngineCtx *DetectEngineCtxInit(void) DetectEngineCtx *DetectEngineCtxInitWithPrefix(const char *prefix) { - return DetectEngineCtxInitReal(0, prefix); + if (prefix == NULL || strlen(prefix) == 0) + return DetectEngineCtxInit(); + else + return DetectEngineCtxInitReal(0, prefix); } static void DetectEngineCtxFreeThreadKeywordData(DetectEngineCtx *de_ctx) @@ -829,6 +832,19 @@ void DetectEngineCtxFree(DetectEngineCtx *de_ctx) DetectEngineCtxFreeThreadKeywordData(de_ctx); SRepDestroy(de_ctx); + + /* if we have a config prefix, remove the config from the tree */ + if (strlen(de_ctx->config_prefix) > 0) { + /* remove config */ + ConfNode *node = ConfGetNode(de_ctx->config_prefix); + if (node != NULL) { + ConfNodeRemove(node); /* frees node */ + } +#if 0 + ConfDump(); +#endif + } + SCFree(de_ctx); //DetectAddressGroupPrintMemory(); //DetectSigGroupPrintMemory();