]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
iprep: cleanup ctx on shutdown
authorVictor Julien <victor@inliniac.net>
Sun, 26 Oct 2014 08:02:08 +0000 (09:02 +0100)
committerVictor Julien <victor@inliniac.net>
Sun, 26 Oct 2014 08:02:08 +0000 (09:02 +0100)
~~Dr.M~~ Error #1: LEAK 480 direct bytes 0x0aae7fc0-0x0aae81a0 + 0 indirect bytes
~~Dr.M~~ # 0 replace_malloc                    [/work/drmemory_package/common/alloc_replace.c:2373]
~~Dr.M~~ # 1 SRepInit                          [.../Suricata/src/reputation.c:594]
~~Dr.M~~ # 2 DetectEngineCtxInit               [.../src/detect-engine.c:844]
~~Dr.M~~ # 3 main                              [.../Suricata/src/suricata.c:2230]

src/detect-engine.c
src/reputation.c
src/reputation.h

index 6c60a8540f62784cdb7b0f1382cbabc953858d09..6b80748fbecbd03d172b6bb73d759d6f979ce608 100644 (file)
@@ -916,6 +916,7 @@ void DetectEngineCtxFree(DetectEngineCtx *de_ctx)
     }
 
     DetectEngineCtxFreeThreadKeywordData(de_ctx);
+    SRepDestroy(de_ctx);
     SCFree(de_ctx);
     //DetectAddressGroupPrintMemory();
     //DetectSigGroupPrintMemory();
index bce8946ad7bd1b43091bd1bf218cc305456dc84d..23484f08b05cba60182a054355aae0393d9105fc 100644 (file)
@@ -664,6 +664,26 @@ int SRepInit(DetectEngineCtx *de_ctx)
     return 0;
 }
 
+void SRepDestroy(DetectEngineCtx *de_ctx) {
+    if (de_ctx->srepCIDR_ctx != NULL) {
+        int i;
+        for (i = 0; i < SREP_MAX_CATS; i++) {
+            if (de_ctx->srepCIDR_ctx->srepIPV4_tree[i] != NULL) {
+                SCRadixReleaseRadixTree(de_ctx->srepCIDR_ctx->srepIPV4_tree[i]);
+                de_ctx->srepCIDR_ctx->srepIPV4_tree[i] = NULL;
+            }
+
+            if (de_ctx->srepCIDR_ctx->srepIPV6_tree[i] != NULL) {
+                SCRadixReleaseRadixTree(de_ctx->srepCIDR_ctx->srepIPV6_tree[i]);
+                de_ctx->srepCIDR_ctx->srepIPV6_tree[i] = NULL;
+            }
+        }
+
+        SCFree(de_ctx->srepCIDR_ctx);
+        de_ctx->srepCIDR_ctx = NULL;
+    }
+}
+
 #ifdef UNITTESTS
 
 #include "conf-yaml-loader.h"
index d489b1ff807c2b2b009a024d3f230c0b104385ad..347731fe7b4c8f26f85269878e0c24abccf8508f 100644 (file)
@@ -42,6 +42,7 @@ typedef struct SReputation_ {
 
 uint8_t SRepCatGetByShortname(char *shortname);
 int SRepInit(struct DetectEngineCtx_ *de_ctx);
+void SRepDestroy(struct DetectEngineCtx_ *de_ctx);
 void SRepReloadComplete(void);
 int SRepHostTimedOut(Host *);