Fix potential double free in sslapitest.c
authorNan Xiao <nan@chinadtrace.org>
Thu, 1 Apr 2021 05:55:04 +0000 (13:55 +0800)
committerPauli <pauli@openssl.org>
Tue, 6 Apr 2021 23:09:13 +0000 (09:09 +1000)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14758)

(cherry picked from commit 493e78986f9677c2b321273da51c276b9a8182d8)

test/sslapitest.c

index 4a27ee1ba260b887f48a5717c7ffdf150a44d04a..665aa13c23efb0307623f1124b84f72d60e2b9ac 100644 (file)
@@ -1826,8 +1826,10 @@ static int execute_test_ssl_bio(int pop_ssl, bio_change_t change_bio)
 
     /* Verify changing the rbio/wbio directly does not cause leaks */
     if (change_bio != NO_BIO_CHANGE) {
-        if (!TEST_ptr(membio2 = BIO_new(BIO_s_mem())))
+        if (!TEST_ptr(membio2 = BIO_new(BIO_s_mem()))) {
+            ssl = NULL;
             goto end;
+        }
         if (change_bio == CHANGE_RBIO)
             SSL_set0_rbio(ssl, membio2);
         else