]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect: remove config at prefix
authorVictor Julien <victor@inliniac.net>
Thu, 5 Mar 2015 12:00:33 +0000 (13:00 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 19 Mar 2015 17:02:19 +0000 (18:02 +0100)
Remove config at prefix when freeing a detect engine.

src/detect-engine.c

index 688c41961584a5aaa5a19afefb117d458123d4cd..df728ed0594679767e86727b4ac344deab4c73e6 100644 (file)
@@ -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();