drbgtest: avoid a memory leak
authorPauli <paul.dale@oracle.com>
Thu, 6 Aug 2020 01:11:44 +0000 (11:11 +1000)
committerPauli <paul.dale@oracle.com>
Fri, 7 Aug 2020 04:16:47 +0000 (14:16 +1000)
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/12509)

test/drbgtest.c

index 2d72055cc7ef12be7c858c6025256e784f3da5c7..c6c8438e98dc5468e806d94202793db068f5d8ff 100644 (file)
@@ -627,6 +627,13 @@ err:
 
 int setup_tests(void)
 {
+    /*
+     * TODO(3.0): figure out why and fix.
+     * Create the primary DRBG here to avoid a memory leak if it is done in
+     * the test cases.
+     */
+    if (RAND_get0_primary(NULL) == NULL)
+        return 0;
     ADD_TEST(test_rand_drbg_reseed);
     ADD_TEST(test_rand_drbg_prediction_resistance);
 #if defined(OPENSSL_THREADS)