From: Eric Leblond Date: Sun, 8 May 2016 22:06:57 +0000 (+0200) Subject: config-test: fix memory leak detect by ASAN X-Git-Tag: suricata-3.1RC1~194 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e29e9056cb83de896d5b06fcf4d049169750901e;p=thirdparty%2Fsuricata.git config-test: fix memory leak detect by ASAN 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. --- diff --git a/src/suricata.c b/src/suricata.c index ee0d40fff7..d6285382ac 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -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); }