From: Victor Julien Date: Thu, 7 Apr 2022 12:44:26 +0000 (+0200) Subject: nss: use 'atexit()' to cleanup X-Git-Tag: suricata-6.0.5~54 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=866d0872bedaafd3c1d96fefc769e64b03271df9;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 42adee2dac..818e36f522 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -356,12 +356,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(); @@ -2469,6 +2463,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. @@ -2630,6 +2634,7 @@ int PostConfLoadedSetup(SCInstance *suri) /* init NSS for hashing */ PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0); NSS_NoDB_Init(NULL); + atexit(AtExitNSSShutdown); } #endif