]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
config-test: fix memory leak detect by ASAN
authorEric Leblond <eric@regit.org>
Sun, 8 May 2016 22:06:57 +0000 (00:06 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 9 May 2016 18:30:01 +0000 (20:30 +0200)
NSS library was not deinit at exit resulting in memory leak. As
it is useless for a config test, the patch updates the code so it
is not initialized.

Patch also calls MagicDeinit to free memory used by libmagic.

src/suricata.c

index ee0d40fff737a5db5ad608af1da00804edf2fa9e..d6285382ac5229f4e754c04429a7f7eb98e3171f 100644 (file)
@@ -2353,10 +2353,13 @@ static int PostConfLoadedSetup(SCInstance *suri)
     if (InitSignalHandler(suri) != TM_ECODE_OK)
         SCReturnInt(TM_ECODE_FAILED);
 
+
 #ifdef HAVE_NSS
-    /* init NSS for md5 */
-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);
-    NSS_NoDB_Init(NULL);
+    if (suri->run_mode != RUNMODE_CONF_TEST) {
+        /* init NSS for md5 */
+        PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);
+        NSS_NoDB_Init(NULL);
+    }
 #endif
 
     if (suri->disabled_detect) {
@@ -2536,6 +2539,7 @@ int main(int argc, char **argv)
 
     if (suri.run_mode == RUNMODE_CONF_TEST){
         SCLogNotice("Configuration provided was successfully loaded. Exiting.");
+        MagicDeinit();
         exit(EXIT_SUCCESS);
     }