]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix ssl_free() and thus BIO_free() to respect BIO_NOCLOSE
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>
Mon, 27 Sep 2021 12:22:40 +0000 (14:22 +0200)
committerTomas Mraz <tomas@openssl.org>
Mon, 4 Oct 2021 08:55:39 +0000 (10:55 +0200)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16688)

ssl/bio_ssl.c

index 43747785f0757caf0a6e4d17721f5dc73e2b23b9..401178f0c2e48c6a3719d0665fa10880e5cd1082 100644 (file)
@@ -76,13 +76,12 @@ static int ssl_free(BIO *a)
     if (a == NULL)
         return 0;
     bs = BIO_get_data(a);
-    if (bs->ssl != NULL)
-        SSL_shutdown(bs->ssl);
     if (BIO_get_shutdown(a)) {
+        if (bs->ssl != NULL)
+            SSL_shutdown(bs->ssl);
         if (BIO_get_init(a))
             SSL_free(bs->ssl);
-        /* Clear all flags */
-        BIO_clear_flags(a, ~0);
+        BIO_clear_flags(a, ~0); /* Clear all flags */
         BIO_set_init(a, 0);
     }
     OPENSSL_free(bs);