This is an automated email from the ASF dual-hosted git repository.

masaori pushed a commit to branch quic-latest
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/quic-latest by this push:
     new cbc81bc  Release ssl in QUICTLS destructor
cbc81bc is described below

commit cbc81bcc4aae47bd4c37a28bb4ec74b39c0648e7
Author: scw00 <sc...@apache.org>
AuthorDate: Thu Aug 9 08:45:14 2018 +0800

    Release ssl in QUICTLS destructor
---
 iocore/net/quic/QUICTLS.cc                         |  2 ++
 iocore/net/quic/test/test_QUICHandshakeProtocol.cc | 15 +++++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/iocore/net/quic/QUICTLS.cc b/iocore/net/quic/QUICTLS.cc
index 1923e01..862c25d 100644
--- a/iocore/net/quic/QUICTLS.cc
+++ b/iocore/net/quic/QUICTLS.cc
@@ -33,6 +33,8 @@ constexpr static char tag[] = "quic_tls";
 
 QUICTLS::~QUICTLS()
 {
+  SSL_free(this->_ssl);
+
   delete this->_client_pp;
   delete this->_server_pp;
 }
diff --git a/iocore/net/quic/test/test_QUICHandshakeProtocol.cc 
b/iocore/net/quic/test/test_QUICHandshakeProtocol.cc
index 4e46c3e..22bbfe8 100644
--- a/iocore/net/quic/test/test_QUICHandshakeProtocol.cc
+++ b/iocore/net/quic/test/test_QUICHandshakeProtocol.cc
@@ -175,11 +175,19 @@ TEST_CASE("QUICHandshakeProtocol Full Handshake", 
"[quic]")
   SSL_CTX_set_mode(server_ssl_ctx, SSL_MODE_QUIC_HACK);
 #endif
   BIO *crt_bio(BIO_new_mem_buf(server_crt, sizeof(server_crt)));
-  SSL_CTX_use_certificate(server_ssl_ctx, PEM_read_bio_X509(crt_bio, nullptr, 
nullptr, nullptr));
+  X509 *x509 = PEM_read_bio_X509(crt_bio, nullptr, nullptr, nullptr);
+  SSL_CTX_use_certificate(server_ssl_ctx, x509);
   BIO *key_bio(BIO_new_mem_buf(server_key, sizeof(server_key)));
-  SSL_CTX_use_PrivateKey(server_ssl_ctx, PEM_read_bio_PrivateKey(key_bio, 
nullptr, nullptr, nullptr));
+  EVP_PKEY *pkey = PEM_read_bio_PrivateKey(key_bio, nullptr, nullptr, nullptr);
+  SSL_CTX_use_PrivateKey(server_ssl_ctx, pkey);
   QUICHandshakeProtocol *server = new QUICTLS(SSL_new(server_ssl_ctx), 
NET_VCONNECTION_IN);
 
+  BIO_free(crt_bio);
+  BIO_free(key_bio);
+
+  X509_free(x509);
+  EVP_PKEY_free(pkey);
+
   CHECK(client->initialize_key_materials({reinterpret_cast<const uint8_t 
*>("\x83\x94\xc8\xf0\x3e\x51\x57\x00"), 8}));
   CHECK(server->initialize_key_materials({reinterpret_cast<const uint8_t 
*>("\x83\x94\xc8\xf0\x3e\x51\x57\x00"), 8}));
 
@@ -282,6 +290,9 @@ TEST_CASE("QUICHandshakeProtocol Full Handshake", "[quic]")
   // Teardown
   delete client;
   delete server;
+
+  SSL_CTX_free(server_ssl_ctx);
+  SSL_CTX_free(client_ssl_ctx);
 }
 
 // // HRR - Incorrect DHE Share

Reply via email to