diff options
author | Rich Salz <rsalz@openssl.org> | 2015-04-11 16:32:54 -0400 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2015-04-11 16:32:54 -0400 |
commit | e0e920b1a063f14f36418f8795c96f2c649400e1 (patch) | |
tree | b1704b3c1e380e01ab8fce7806bbd8d1d6997fa2 /ssl | |
parent | a38537721dfdd853c40b4b4d99b57950075b0178 (diff) |
free NULL cleanup 9
Ongoing work to skip NULL check before calling free routine. This gets:
ecp_nistz256_pre_comp_free nistp224_pre_comp_free nistp256_pre_comp_free
nistp521_pre_comp_free PKCS7_free PKCS7_RECIP_INFO_free
PKCS7_SIGNER_INFO_free sk_PKCS7_pop_free PKCS8_PRIV_KEY_INFO_free
PKCS12_free PKCS12_SAFEBAG_free PKCS12_free sk_PKCS12_SAFEBAG_pop_free
SSL_CONF_CTX_free SSL_CTX_free SSL_SESSION_free SSL_free ssl_cert_free
ssl_sess_cert_free
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Diffstat (limited to 'ssl')
-rw-r--r-- | ssl/ssl_lib.c | 25 | ||||
-rw-r--r-- | ssl/ssl_sess.c | 13 |
2 files changed, 12 insertions, 26 deletions
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index cb7bd86e2a..42ee3a918c 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -568,15 +568,13 @@ void SSL_free(SSL *s) ssl_clear_hash_ctx(&s->read_hash); ssl_clear_hash_ctx(&s->write_hash); - if (s->cert != NULL) - ssl_cert_free(s->cert); + ssl_cert_free(s->cert); /* Free up if allocated */ #ifndef OPENSSL_NO_TLSEXT if (s->tlsext_hostname) OPENSSL_free(s->tlsext_hostname); - if (s->initial_ctx) - SSL_CTX_free(s->initial_ctx); + SSL_CTX_free(s->initial_ctx); # ifndef OPENSSL_NO_EC if (s->tlsext_ecpointformatlist) OPENSSL_free(s->tlsext_ecpointformatlist); @@ -601,8 +599,7 @@ void SSL_free(SSL *s) RECORD_LAYER_release(&s->rlayer); - if (s->ctx) - SSL_CTX_free(s->ctx); + SSL_CTX_free(s->ctx); #ifndef OPENSSL_NO_KRB5 if (s->kssl_ctx != NULL) @@ -2011,8 +2008,7 @@ SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth) err: SSLerr(SSL_F_SSL_CTX_NEW, ERR_R_MALLOC_FAILURE); err2: - if (ret != NULL) - SSL_CTX_free(ret); + SSL_CTX_free(ret); return (NULL); } @@ -2062,8 +2058,7 @@ void SSL_CTX_free(SSL_CTX *a) sk_SSL_CIPHER_free(a->cipher_list); if (a->cipher_list_by_id != NULL) sk_SSL_CIPHER_free(a->cipher_list_by_id); - if (a->cert != NULL) - ssl_cert_free(a->cert); + ssl_cert_free(a->cert); if (a->client_CA != NULL) sk_X509_NAME_pop_free(a->client_CA, X509_NAME_free); if (a->extra_certs != NULL) @@ -2776,9 +2771,7 @@ SSL *SSL_dup(SSL *s) ret->method->ssl_new(ret); if (s->cert != NULL) { - if (ret->cert != NULL) { - ssl_cert_free(ret->cert); - } + ssl_cert_free(ret->cert); ret->cert = ssl_cert_dup(s->cert); if (ret->cert == NULL) goto err; @@ -2862,8 +2855,7 @@ SSL *SSL_dup(SSL *s) if (0) { err: - if (ret != NULL) - SSL_free(ret); + SSL_free(ret); ret = NULL; } return (ret); @@ -3092,8 +3084,7 @@ SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx) } CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX); - if (ssl->ctx != NULL) - SSL_CTX_free(ssl->ctx); /* decrement reference count */ + SSL_CTX_free(ssl->ctx); /* decrement reference count */ ssl->ctx = ctx; return (ssl->ctx); diff --git a/ssl/ssl_sess.c b/ssl/ssl_sess.c index 24e5d259d4..a213ea90df 100644 --- a/ssl/ssl_sess.c +++ b/ssl/ssl_sess.c @@ -726,8 +726,7 @@ void SSL_SESSION_free(SSL_SESSION *ss) OPENSSL_cleanse(ss->master_key, sizeof ss->master_key); OPENSSL_cleanse(ss->session_id, sizeof ss->session_id); - if (ss->sess_cert != NULL) - ssl_sess_cert_free(ss->sess_cert); + ssl_sess_cert_free(ss->sess_cert); if (ss->peer != NULL) X509_free(ss->peer); if (ss->ciphers != NULL) @@ -795,18 +794,14 @@ int SSL_set_session(SSL *s, SSL_SESSION *session) /* CRYPTO_w_lock(CRYPTO_LOCK_SSL); */ CRYPTO_add(&session->references, 1, CRYPTO_LOCK_SSL_SESSION); - if (s->session != NULL) - SSL_SESSION_free(s->session); + SSL_SESSION_free(s->session); s->session = session; s->verify_result = s->session->verify_result; /* CRYPTO_w_unlock(CRYPTO_LOCK_SSL); */ ret = 1; } else { - if (s->session != NULL) { - SSL_SESSION_free(s->session); - s->session = NULL; - } - + SSL_SESSION_free(s->session); + s->session = NULL; meth = s->ctx->method; if (meth != s->method) { if (!SSL_set_ssl_method(s, meth)) |