summaryrefslogtreecommitdiffstats
path: root/ssl
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2015-03-25 11:31:18 -0400
committerRich Salz <rsalz@openssl.org>2015-03-25 11:31:18 -0400
commitca3a82c3b364e1e584546f0f3bbb938b0b472580 (patch)
tree06c73d297f19629c1bf56bbf06dd2d443d4ac78f /ssl
parent2011b169fa90edd4d986e7dbbd3d64587d316a22 (diff)
free NULL cleanup
This commit handles BIO_ACCEPT_free BIO_CB_FREE BIO_CONNECT_free BIO_free BIO_free_all BIO_vfree Reviewed-by: Matt Caswell <matt@openssl.org>
Diffstat (limited to 'ssl')
-rw-r--r--ssl/bio_ssl.c9
-rw-r--r--ssl/s3_enc.c3
-rw-r--r--ssl/s3_lib.c10
-rw-r--r--ssl/ssl_cert.c6
-rw-r--r--ssl/ssl_conf.c3
-rw-r--r--ssl/ssl_lib.c9
-rw-r--r--ssl/ssl_rsa.c24
-rw-r--r--ssl/ssl_task.c12
-rw-r--r--ssl/ssltest.c36
9 files changed, 38 insertions, 74 deletions
diff --git a/ssl/bio_ssl.c b/ssl/bio_ssl.c
index 99f8b5e524..11a2aadc5f 100644
--- a/ssl/bio_ssl.c
+++ b/ssl/bio_ssl.c
@@ -503,10 +503,8 @@ BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx)
goto err;
return (ret);
err:
- if (buf != NULL)
- BIO_free(buf);
- if (ssl != NULL)
- BIO_free(ssl);
+ BIO_free(buf);
+ BIO_free(ssl);
#endif
return (NULL);
}
@@ -524,8 +522,7 @@ BIO *BIO_new_ssl_connect(SSL_CTX *ctx)
goto err;
return (ret);
err:
- if (con != NULL)
- BIO_free(con);
+ BIO_free(con);
#endif
return (NULL);
}
diff --git a/ssl/s3_enc.c b/ssl/s3_enc.c
index bcefe12769..94f6dd0647 100644
--- a/ssl/s3_enc.c
+++ b/ssl/s3_enc.c
@@ -558,8 +558,7 @@ int ssl3_enc(SSL *s, int send)
void ssl3_init_finished_mac(SSL *s)
{
- if (s->s3->handshake_buffer)
- BIO_free(s->s3->handshake_buffer);
+ BIO_free(s->s3->handshake_buffer);
if (s->s3->handshake_dgst)
ssl3_free_digest_list(s);
s->s3->handshake_buffer = BIO_new(BIO_s_mem());
diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c
index 9893930eef..bed4a4e72d 100644
--- a/ssl/s3_lib.c
+++ b/ssl/s3_lib.c
@@ -3147,9 +3147,7 @@ void ssl3_free(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->handshake_buffer) {
- BIO_free(s->s3->handshake_buffer);
- }
+ BIO_free(s->s3->handshake_buffer);
if (s->s3->handshake_dgst)
ssl3_free_digest_list(s);
#ifndef OPENSSL_NO_TLSEXT
@@ -3200,10 +3198,8 @@ void ssl3_clear(SSL *s)
rlen = s->s3->rbuf.len;
wlen = s->s3->wbuf.len;
init_extra = s->s3->init_extra;
- if (s->s3->handshake_buffer) {
- BIO_free(s->s3->handshake_buffer);
- s->s3->handshake_buffer = NULL;
- }
+ BIO_free(s->s3->handshake_buffer);
+ s->s3->handshake_buffer = NULL;
if (s->s3->handshake_dgst) {
ssl3_free_digest_list(s);
}
diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c
index cbfe7bb416..367f7a9603 100644
--- a/ssl/ssl_cert.c
+++ b/ssl/ssl_cert.c
@@ -877,8 +877,7 @@ STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file)
}
if (sk != NULL)
sk_X509_NAME_free(sk);
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
if (x != NULL)
X509_free(x);
if (ret != NULL)
@@ -938,8 +937,7 @@ int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
err:
ret = 0;
}
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
if (x != NULL)
X509_free(x);
diff --git a/ssl/ssl_conf.c b/ssl/ssl_conf.c
index 0fd6c1f1be..43821f6f37 100644
--- a/ssl/ssl_conf.c
+++ b/ssl/ssl_conf.c
@@ -438,8 +438,7 @@ static int cmd_DHParameters(SSL_CONF_CTX *cctx, const char *value)
rv = SSL_set_tmp_dh(cctx->ssl, dh);
end:
DH_free(dh);
- if (in)
- BIO_free(in);
+ BIO_free(in);
return rv > 0;
}
#endif
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index 29bbc03e4c..1e9ad91c46 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -543,9 +543,8 @@ void SSL_free(SSL *s)
BIO_free(s->bbio);
s->bbio = NULL;
}
- if (s->rbio != NULL)
- BIO_free_all(s->rbio);
- if ((s->wbio != NULL) && (s->wbio != s->rbio))
+ BIO_free_all(s->rbio);
+ if (s->wbio != s->rbio)
BIO_free_all(s->wbio);
if (s->init_buf != NULL)
@@ -621,7 +620,7 @@ void SSL_free(SSL *s)
void SSL_set_rbio(SSL *s, BIO *rbio)
{
- if ((s->rbio != NULL) && (s->rbio != rbio))
+ if (s->rbio != rbio)
BIO_free_all(s->rbio);
s->rbio = rbio;
}
@@ -637,7 +636,7 @@ void SSL_set_wbio(SSL *s, BIO *wbio)
s->bbio->next_bio = NULL;
}
}
- if ((s->wbio != NULL) && (s->wbio != wbio) && (s->rbio != s->wbio))
+ if (s->wbio != wbio && s->rbio != s->wbio)
BIO_free_all(s->wbio);
s->wbio = wbio;
}
diff --git a/ssl/ssl_rsa.c b/ssl/ssl_rsa.c
index 60a68340d1..90fe8c8af9 100644
--- a/ssl/ssl_rsa.c
+++ b/ssl/ssl_rsa.c
@@ -121,8 +121,7 @@ int SSL_use_certificate_file(SSL *ssl, const char *file, int type)
end:
if (x != NULL)
X509_free(x);
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
return (ret);
}
#endif
@@ -262,8 +261,7 @@ int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type)
ret = SSL_use_RSAPrivateKey(ssl, rsa);
RSA_free(rsa);
end:
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
return (ret);
}
# endif
@@ -335,8 +333,7 @@ int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type)
ret = SSL_use_PrivateKey(ssl, pkey);
EVP_PKEY_free(pkey);
end:
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
return (ret);
}
#endif
@@ -470,8 +467,7 @@ int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type)
end:
if (x != NULL)
X509_free(x);
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
return (ret);
}
#endif
@@ -552,8 +548,7 @@ int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type)
ret = SSL_CTX_use_RSAPrivateKey(ctx, rsa);
RSA_free(rsa);
end:
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
return (ret);
}
# endif
@@ -622,8 +617,7 @@ int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type)
ret = SSL_CTX_use_PrivateKey(ctx, pkey);
EVP_PKEY_free(pkey);
end:
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
return (ret);
}
#endif
@@ -726,8 +720,7 @@ int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file)
end:
if (x != NULL)
X509_free(x);
- if (in != NULL)
- BIO_free(in);
+ BIO_free(in);
return (ret);
}
#endif
@@ -991,8 +984,7 @@ int SSL_CTX_use_serverinfo_file(SSL_CTX *ctx, const char *file)
OPENSSL_free(header);
OPENSSL_free(extension);
OPENSSL_free(serverinfo);
- if (bin != NULL)
- BIO_free(bin);
+ BIO_free(bin);
return ret;
}
# endif /* OPENSSL_NO_STDIO */
diff --git a/ssl/ssl_task.c b/ssl/ssl_task.c
index ab37cc6bef..d5ca89feb8 100644
--- a/ssl/ssl_task.c
+++ b/ssl/ssl_task.c
@@ -381,13 +381,9 @@ int doit(io_channel chan, SSL_CTX *s_ctx)
s_ssl->rbio = NULL;
s_ssl->wbio = NULL;
- if (c_to_s != NULL)
- BIO_free(c_to_s);
- if (s_to_c != NULL)
- BIO_free(s_to_c);
- if (c_bio != NULL)
- BIO_free(c_bio);
- if (s_bio != NULL)
- BIO_free(s_bio);
+ BIO_free(c_to_s);
+ BIO_free(s_to_c);
+ BIO_free(c_bio);
+ BIO_free(s_bio);
return (0);
}
diff --git a/ssl/ssltest.c b/ssl/ssltest.c
index d244ba3cd9..508fedd613 100644
--- a/ssl/ssltest.c
+++ b/ssl/ssltest.c
@@ -1798,8 +1798,7 @@ int main(int argc, char *argv[])
SSL_CONF_CTX_free(c_cctx);
sk_OPENSSL_STRING_free(conf_args);
- if (bio_stdout != NULL)
- BIO_free(bio_stdout);
+ BIO_free(bio_stdout);
#ifndef OPENSSL_NO_RSA
free_tmp_rsa();
@@ -1812,8 +1811,7 @@ int main(int argc, char *argv[])
ERR_remove_thread_state(NULL);
EVP_cleanup();
CRYPTO_mem_leaks(bio_err);
- if (bio_err != NULL)
- BIO_free(bio_err);
+ BIO_free(bio_err);
EXIT(ret);
}
@@ -2173,18 +2171,12 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count,
err:
ERR_print_errors(bio_err);
- if (server)
- BIO_free(server);
- if (server_io)
- BIO_free(server_io);
- if (client)
- BIO_free(client);
- if (client_io)
- BIO_free(client_io);
- if (s_ssl_bio)
- BIO_free(s_ssl_bio);
- if (c_ssl_bio)
- BIO_free(c_ssl_bio);
+ BIO_free(server);
+ BIO_free(server_io);
+ BIO_free(client);
+ BIO_free(client_io);
+ BIO_free(s_ssl_bio);
+ BIO_free(c_ssl_bio);
return ret;
}
@@ -2468,14 +2460,10 @@ int doit(SSL *s_ssl, SSL *c_ssl, long count)
c_ssl->wbio = NULL;
}
- if (c_to_s != NULL)
- BIO_free(c_to_s);
- if (s_to_c != NULL)
- BIO_free(s_to_c);
- if (c_bio != NULL)
- BIO_free_all(c_bio);
- if (s_bio != NULL)
- BIO_free_all(s_bio);
+ BIO_free(c_to_s);
+ BIO_free(s_to_c);
+ BIO_free_all(c_bio);
+ BIO_free_all(s_bio);
if (cbuf)
OPENSSL_free(cbuf);