From: Victor Julien Date: Thu, 7 Apr 2022 12:44:26 +0000 (+0200) Subject: nss: use 'atexit()' to cleanup X-Git-Tag: suricata-5.0.9~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F7214%2Fhead;p=thirdparty%2Fsuricata.git nss: use 'atexit()' to cleanup This avoids ASAN to report leaks in case of fatal errors in tests. --- diff --git a/src/suricata.c b/src/suricata.c index 762d3598b7..c4bdc1cb33 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -394,12 +394,6 @@ static void GlobalsDestroy(SCInstance *suri) TmqhCleanup(); TmModuleRunDeInit(); ParseSizeDeinit(); -#ifdef HAVE_NSS - if (NSS_IsInitialized()) { - NSS_Shutdown(); - PR_Cleanup(); - } -#endif #ifdef HAVE_AF_PACKET AFPPeersListClean(); @@ -2760,6 +2754,16 @@ static void SetupUserMode(SCInstance *suri) } } +#ifdef HAVE_NSS +static void AtExitNSSShutdown(void) +{ + if (NSS_IsInitialized()) { + NSS_Shutdown(); + PR_Cleanup(); + } +} +#endif + /** * This function is meant to contain code that needs * to be run once the configuration has been loaded. @@ -2915,6 +2919,7 @@ static int PostConfLoadedSetup(SCInstance *suri) /* init NSS for hashing */ PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0); NSS_NoDB_Init(NULL); + atexit(AtExitNSSShutdown); } #endif