summaryrefslogtreecommitdiffstats
path: root/crypto/rand
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2019-08-21 10:12:05 +0200
committerRichard Levitte <levitte@openssl.org>2019-08-22 01:50:30 +0200
commit85d09e8848012d0dfdacf827d9d56730fa5daf16 (patch)
tree382d1c2fb306ae564fbb03740de676a5a541ad88 /crypto/rand
parentc1d56231ef6385b557ec72eec508e55ea26ca8b0 (diff)
Fix drbg_ossl_ctx_free() and drbg_nonce_ossl_ctx_free() to handle NULL
If these were passed NULL, the crashed with a SIGSEGV, when they should do like all other freeing functions and become a no-op. Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/9650)
Diffstat (limited to 'crypto/rand')
-rw-r--r--crypto/rand/drbg_lib.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/crypto/rand/drbg_lib.c b/crypto/rand/drbg_lib.c
index 825e90d48e..f8b58d7245 100644
--- a/crypto/rand/drbg_lib.c
+++ b/crypto/rand/drbg_lib.c
@@ -191,6 +191,9 @@ static void drbg_ossl_ctx_free(void *vdgbl)
{
DRBG_GLOBAL *dgbl = vdgbl;
+ if (dgbl == NULL)
+ return;
+
RAND_DRBG_free(dgbl->master_drbg);
CRYPTO_THREAD_cleanup_local(&dgbl->private_drbg);
CRYPTO_THREAD_cleanup_local(&dgbl->public_drbg);
@@ -230,6 +233,9 @@ static void drbg_nonce_ossl_ctx_free(void *vdngbl)
{
DRBG_NONCE_GLOBAL *dngbl = vdngbl;
+ if (dngbl == NULL)
+ return;
+
CRYPTO_THREAD_lock_free(dngbl->rand_nonce_lock);
OPENSSL_free(dngbl);