diff options
author | Rich Salz <rsalz@openssl.org> | 2018-03-27 16:25:08 -0400 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2018-03-27 16:25:08 -0400 |
commit | e6e9170d6e28038768895e1af18e3aad8093bf4b (patch) | |
tree | 62f594f0968ff8d6c27795377a102e4aab373b00 /ssl | |
parent | 98c03302fb7b855647aa14022f61f5fb272e514a (diff) |
Allow NULL for some _free routines.
Based on the description in https://github.com/openssl/openssl/pull/5757,
this re-implements the "allow NULL to be passed" behavior of a number of
xxx_free routines. I also fixed up some egregious formatting errors
that were nearby.
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5761)
Diffstat (limited to 'ssl')
-rw-r--r-- | ssl/s3_lib.c | 2 | ||||
-rw-r--r-- | ssl/ssl_cert.c | 2 | ||||
-rw-r--r-- | ssl/ssl_lib.c | 2 | ||||
-rw-r--r-- | ssl/ssl_sess.c | 2 |
4 files changed, 7 insertions, 1 deletions
diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c index 78a5a3a2e2..619326949c 100644 --- a/ssl/s3_lib.c +++ b/ssl/s3_lib.c @@ -3312,7 +3312,7 @@ int ssl3_new(SSL *s) void ssl3_free(SSL *s) { - if (s->s3 == NULL) + if (s == NULL || s->s3 == NULL) return; ssl3_cleanup_key_block(s); diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c index 5a465e3942..b2b342767c 100644 --- a/ssl/ssl_cert.c +++ b/ssl/ssl_cert.c @@ -225,6 +225,8 @@ void ssl_cert_free(CERT *c) { int i; + if (c == NULL) + return; CRYPTO_DOWN_REF(&c->references, &i, c->lock); REF_PRINT_COUNT("CERT", c); if (i > 0) diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index b678fcfbbb..9d4c4d4899 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -1125,6 +1125,8 @@ void SSL_free(SSL *s) { int i; + if (s == NULL) + return; CRYPTO_DOWN_REF(&s->references, &i, s->lock); REF_PRINT_COUNT("SSL", s); if (i > 0) diff --git a/ssl/ssl_sess.c b/ssl/ssl_sess.c index 1672cd2a95..f936cb687f 100644 --- a/ssl/ssl_sess.c +++ b/ssl/ssl_sess.c @@ -785,6 +785,8 @@ void SSL_SESSION_free(SSL_SESSION *ss) { int i; + if (ss == NULL) + return; CRYPTO_DOWN_REF(&ss->references, &i, ss->lock); REF_PRINT_COUNT("SSL_SESSION", ss); if (i > 0) |