Avoid duplication.
authorDr. Stephen Henson <steve@openssl.org>
Sat, 20 Jun 2015 14:44:03 +0000 (15:44 +0100)
committerDr. Stephen Henson <steve@openssl.org>
Sun, 21 Jun 2015 14:29:22 +0000 (15:29 +0100)
We always free the handshake buffer when digests are freed so move
it into ssl_free_digest_list()

Reviewed-by: Rich Salz <rsalz@openssl.org>
ssl/s3_enc.c
ssl/s3_lib.c

index bde19e1fb8ad3bc6a9bf0a502d46d230620f8f32..eedf74d392a61776ee4555911e8ce0816a71e2d6 100644 (file)
@@ -476,15 +476,21 @@ void ssl3_cleanup_key_block(SSL *s)
 
 void ssl3_init_finished_mac(SSL *s)
 {
-    BIO_free(s->s3->handshake_buffer);
     ssl3_free_digest_list(s);
     s->s3->handshake_buffer = BIO_new(BIO_s_mem());
     (void)BIO_set_close(s->s3->handshake_buffer, BIO_CLOSE);
 }
 
+/*
+ * Free digest list. Also frees handshake buffer since they are always freed
+ * together.
+ */
+
 void ssl3_free_digest_list(SSL *s)
 {
     int i;
+    BIO_free(s->s3->handshake_buffer);
+    s->s3->handshake_buffer = NULL;
     if (!s->s3->handshake_dgst)
         return;
     for (i = 0; i < SSL_MAX_DIGEST; i++) {
index 03078016e694b534fc1a794213767239bd0a3a07..36b5f0d3abdb6a1aa893b09cf9b974f8cd0c7d38 100644 (file)
@@ -2905,7 +2905,6 @@ void ssl3_free(SSL *s)
     OPENSSL_free(s->s3->tmp.ciphers_raw);
     OPENSSL_clear_free(s->s3->tmp.pms, s->s3->tmp.pmslen);
     OPENSSL_free(s->s3->tmp.peer_sigalgs);
-    BIO_free(s->s3->handshake_buffer);
     ssl3_free_digest_list(s);
     OPENSSL_free(s->s3->alpn_selected);
 
@@ -2940,8 +2939,6 @@ void ssl3_clear(SSL *s)
 #endif                         /* !OPENSSL_NO_EC */
 
     init_extra = s->s3->init_extra;
-    BIO_free(s->s3->handshake_buffer);
-    s->s3->handshake_buffer = NULL;
     ssl3_free_digest_list(s);
 
     if (s->s3->alpn_selected) {