From 1904ce01988b6ea0f5775507b4d812459c5b3f50 Mon Sep 17 00:00:00 2001 From: jsing <> Date: Wed, 28 May 2014 13:03:25 +0000 Subject: There is no point in checking if a pointer is non-NULL before calling free, since free already does this for us. Also remove some pointless NULL assignments, where the result from malloc(3) is immediately assigned to the same variable. ok miod@ --- src/lib/libssl/s3_lib.c | 39 ++++++++++++++------------------------- 1 file changed, 14 insertions(+), 25 deletions(-) (limited to 'src/lib/libssl/s3_lib.c') diff --git a/src/lib/libssl/s3_lib.c b/src/lib/libssl/s3_lib.c index d8a186040b..2f4ab38863 100644 --- a/src/lib/libssl/s3_lib.c +++ b/src/lib/libssl/s3_lib.c @@ -2332,10 +2332,8 @@ ssl3_free(SSL *s) return; #ifdef TLSEXT_TYPE_opaque_prf_input - if (s->s3->client_opaque_prf_input != NULL) - free(s->s3->client_opaque_prf_input); - if (s->s3->server_opaque_prf_input != NULL) - free(s->s3->server_opaque_prf_input); + free(s->s3->client_opaque_prf_input); + free(s->s3->server_opaque_prf_input); #endif ssl3_cleanup_key_block(s); @@ -2343,8 +2341,7 @@ ssl3_free(SSL *s) ssl3_release_read_buffer(s); if (s->s3->wbuf.buf != NULL) ssl3_release_write_buffer(s); - if (s->s3->rrec.comp != NULL) - free(s->s3->rrec.comp); + free(s->s3->rrec.comp); #ifndef OPENSSL_NO_DH if (s->s3->tmp.dh != NULL) DH_free(s->s3->tmp.dh); @@ -2374,11 +2371,9 @@ ssl3_clear(SSL *s) int init_extra; #ifdef TLSEXT_TYPE_opaque_prf_input - if (s->s3->client_opaque_prf_input != NULL) - free(s->s3->client_opaque_prf_input); + free(s->s3->client_opaque_prf_input); s->s3->client_opaque_prf_input = NULL; - if (s->s3->server_opaque_prf_input != NULL) - free(s->s3->server_opaque_prf_input); + free(s->s3->server_opaque_prf_input); s->s3->server_opaque_prf_input = NULL; #endif @@ -2386,10 +2381,9 @@ ssl3_clear(SSL *s) if (s->s3->tmp.ca_names != NULL) sk_X509_NAME_pop_free(s->s3->tmp.ca_names, X509_NAME_free); - if (s->s3->rrec.comp != NULL) { - free(s->s3->rrec.comp); - s->s3->rrec.comp = NULL; - } + free(s->s3->rrec.comp); + s->s3->rrec.comp = NULL; + #ifndef OPENSSL_NO_DH if (s->s3->tmp.dh != NULL) { DH_free(s->s3->tmp.dh); @@ -2437,11 +2431,9 @@ ssl3_clear(SSL *s) s->version = SSL3_VERSION; #if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) - if (s->next_proto_negotiated) { - free(s->next_proto_negotiated); - s->next_proto_negotiated = NULL; - s->next_proto_negotiated_len = 0; - } + free(s->next_proto_negotiated); + s->next_proto_negotiated = NULL; + s->next_proto_negotiated_len = 0; #endif } @@ -2589,8 +2581,7 @@ ssl3_ctrl(SSL *s, int cmd, long larg, void *parg) #ifndef OPENSSL_NO_TLSEXT case SSL_CTRL_SET_TLSEXT_HOSTNAME: if (larg == TLSEXT_NAMETYPE_host_name) { - if (s->tlsext_hostname != NULL) - free(s->tlsext_hostname); + free(s->tlsext_hostname); s->tlsext_hostname = NULL; ret = 1; @@ -2630,8 +2621,7 @@ ssl3_ctrl(SSL *s, int cmd, long larg, void *parg) SSL_R_OPAQUE_PRF_INPUT_TOO_LONG); break; } - if (s->tlsext_opaque_prf_input != NULL) - free(s->tlsext_opaque_prf_input); + free(s->tlsext_opaque_prf_input); if ((size_t)larg == 0) { s->tlsext_opaque_prf_input = NULL; s->tlsext_opaque_prf_input_len = 0; @@ -2678,8 +2668,7 @@ ssl3_ctrl(SSL *s, int cmd, long larg, void *parg) return s->tlsext_ocsp_resplen; case SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP: - if (s->tlsext_ocsp_resp) - free(s->tlsext_ocsp_resp); + free(s->tlsext_ocsp_resp); s->tlsext_ocsp_resp = parg; s->tlsext_ocsp_resplen = larg; ret = 1; -- cgit v1.2.3-55-g6feb