]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
nss: use 'atexit()' to cleanup 7214/head
authorVictor Julien <vjulien@oisf.net>
Thu, 7 Apr 2022 12:44:26 +0000 (14:44 +0200)
committerVictor Julien <vjulien@oisf.net>
Thu, 7 Apr 2022 16:19:01 +0000 (18:19 +0200)
This avoids ASAN to report leaks in case of fatal errors in tests.

src/suricata.c

index 762d3598b7016652a91a4e998166b41875e3781c..c4bdc1cb33a81e4f40a9cd61a0523bc40bdab688 100644 (file)
@@ -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