summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2014-05-29 14:43:33 +0000
committerjsing <>2014-05-29 14:43:33 +0000
commit58eb928f74719c054467fb1c9ed254eab20bf136 (patch)
tree633b4af45ff52c60c62641a1a63b149bfb789e6e /src
parent90a27dd2630fc2f77d90209add109a18beb0f2e2 (diff)
downloadopenbsd-58eb928f74719c054467fb1c9ed254eab20bf136.tar.gz
openbsd-58eb928f74719c054467fb1c9ed254eab20bf136.tar.bz2
openbsd-58eb928f74719c054467fb1c9ed254eab20bf136.zip
When you have functions that perform specific functions, use them.
EVP_CIPHER_CTX_free() does a NULL check, then calls EVP_CIPHER_CTX_cleanup() and frees the memory. COMP_CTX_free() also had its own NULL check, so there is no point in duplicating that here. ok beck@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libssl/src/ssl/ssl_lib.c27
-rw-r--r--src/lib/libssl/ssl_lib.c27
2 files changed, 18 insertions, 36 deletions
diff --git a/src/lib/libssl/src/ssl/ssl_lib.c b/src/lib/libssl/src/ssl/ssl_lib.c
index 12d45ea025..f1c92ee2f6 100644
--- a/src/lib/libssl/src/ssl/ssl_lib.c
+++ b/src/lib/libssl/src/ssl/ssl_lib.c
@@ -2726,25 +2726,16 @@ SSL_dup(SSL *s)
2726void 2726void
2727ssl_clear_cipher_ctx(SSL *s) 2727ssl_clear_cipher_ctx(SSL *s)
2728{ 2728{
2729 if (s->enc_read_ctx != NULL) { 2729 EVP_CIPHER_CTX_free(s->enc_read_ctx);
2730 EVP_CIPHER_CTX_cleanup(s->enc_read_ctx); 2730 s->enc_read_ctx = NULL;
2731 free(s->enc_read_ctx); 2731 EVP_CIPHER_CTX_free(s->enc_write_ctx);
2732 s->enc_read_ctx = NULL; 2732 s->enc_write_ctx = NULL;
2733 } 2733
2734 if (s->enc_write_ctx != NULL) {
2735 EVP_CIPHER_CTX_cleanup(s->enc_write_ctx);
2736 free(s->enc_write_ctx);
2737 s->enc_write_ctx = NULL;
2738 }
2739#ifndef OPENSSL_NO_COMP 2734#ifndef OPENSSL_NO_COMP
2740 if (s->expand != NULL) { 2735 COMP_CTX_free(s->expand);
2741 COMP_CTX_free(s->expand); 2736 s->expand = NULL;
2742 s->expand = NULL; 2737 COMP_CTX_free(s->compress);
2743 } 2738 s->compress = NULL;
2744 if (s->compress != NULL) {
2745 COMP_CTX_free(s->compress);
2746 s->compress = NULL;
2747 }
2748#endif 2739#endif
2749} 2740}
2750 2741
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c
index 12d45ea025..f1c92ee2f6 100644
--- a/src/lib/libssl/ssl_lib.c
+++ b/src/lib/libssl/ssl_lib.c
@@ -2726,25 +2726,16 @@ SSL_dup(SSL *s)
2726void 2726void
2727ssl_clear_cipher_ctx(SSL *s) 2727ssl_clear_cipher_ctx(SSL *s)
2728{ 2728{
2729 if (s->enc_read_ctx != NULL) { 2729 EVP_CIPHER_CTX_free(s->enc_read_ctx);
2730 EVP_CIPHER_CTX_cleanup(s->enc_read_ctx); 2730 s->enc_read_ctx = NULL;
2731 free(s->enc_read_ctx); 2731 EVP_CIPHER_CTX_free(s->enc_write_ctx);
2732 s->enc_read_ctx = NULL; 2732 s->enc_write_ctx = NULL;
2733 } 2733
2734 if (s->enc_write_ctx != NULL) {
2735 EVP_CIPHER_CTX_cleanup(s->enc_write_ctx);
2736 free(s->enc_write_ctx);
2737 s->enc_write_ctx = NULL;
2738 }
2739#ifndef OPENSSL_NO_COMP 2734#ifndef OPENSSL_NO_COMP
2740 if (s->expand != NULL) { 2735 COMP_CTX_free(s->expand);
2741 COMP_CTX_free(s->expand); 2736 s->expand = NULL;
2742 s->expand = NULL; 2737 COMP_CTX_free(s->compress);
2743 } 2738 s->compress = NULL;
2744 if (s->compress != NULL) {
2745 COMP_CTX_free(s->compress);
2746 s->compress = NULL;
2747 }
2748#endif 2739#endif
2749} 2740}
2750 2741