From d2ee7ceff05e9bcc00a0f88a4cf85e32464f4b9a Mon Sep 17 00:00:00 2001 From: Hugo Landau Date: Thu, 18 Jan 2024 16:33:27 +0000 Subject: [PATCH] Minor fix to BIO refcount handling Reviewed-by: Matt Caswell Reviewed-by: Neil Horman (Merged from https://github.com/openssl/openssl/pull/23334) --- doc/man3/SSL_new_listener.pod | 2 +- ssl/quic/quic_impl.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/doc/man3/SSL_new_listener.pod b/doc/man3/SSL_new_listener.pod index 3431828ece5..b3cbc70ea1f 100644 --- a/doc/man3/SSL_new_listener.pod +++ b/doc/man3/SSL_new_listener.pod @@ -199,7 +199,7 @@ OSSL_QUIC_server_method() was added in OpenSSL @VERSION_QUIC_SERVER@. =head1 COPYRIGHT -Copyright 2022-2024 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2024 The OpenSSL Project Authors. All Rights Reserved. Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy diff --git a/ssl/quic/quic_impl.c b/ssl/quic/quic_impl.c index cbedf009682..e3e56b0e3f8 100644 --- a/ssl/quic/quic_impl.c +++ b/ssl/quic/quic_impl.c @@ -527,8 +527,18 @@ static void qc_cleanup(QUIC_CONNECTION *qc, int have_lock) ossl_quic_channel_free(qc->ch); qc->ch = NULL; - ossl_quic_port_free(qc->port); - qc->port = NULL; + if (qc->port != NULL) { + BIO *b; + + b = ossl_quic_port_get_net_rbio(qc->port); + BIO_free_all(b); + + b = ossl_quic_port_get_net_wbio(qc->port); + BIO_free_all(b); + + ossl_quic_port_free(qc->port); + qc->port = NULL; + } ossl_quic_engine_free(qc->engine); qc->engine = NULL; -- 2.47.3