From f13f9b716e8b148b97dbe49e823b9dc3f235de1f Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Wed, 20 Sep 2023 16:24:37 +0100 Subject: [PATCH] Ensure we up-ref the sbio before passing it to tserver We are actually passing two references to sbio: one as part of a BIO chain and one stand alone. Therefore we need two references. Reviewed-by: Tim Hudson Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/22157) --- test/helpers/quictestlib.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/helpers/quictestlib.c b/test/helpers/quictestlib.c index 6a72cc27bea..f5a46efb6f0 100644 --- a/test/helpers/quictestlib.c +++ b/test/helpers/quictestlib.c @@ -201,8 +201,12 @@ int qtest_create_quic_objects(OSSL_LIB_CTX *libctx, SSL_CTX *clientctx, BIO_set_data(fisbio, fault == NULL ? NULL : *fault); - if (!TEST_ptr(BIO_push(fisbio, sbio))) + if (!BIO_up_ref(sbio)) goto err; + if (!TEST_ptr(BIO_push(fisbio, sbio))) { + BIO_free(sbio); + goto err; + } tserver_args.libctx = libctx; tserver_args.net_rbio = sbio; @@ -240,7 +244,7 @@ int qtest_create_quic_objects(OSSL_LIB_CTX *libctx, SSL_CTX *clientctx, SSL_CTX_free(tserver_args.ctx); BIO_ADDR_free(peeraddr); BIO_free_all(cbio); - BIO_free(fisbio); + BIO_free_all(fisbio); BIO_free_all(sbio); SSL_free(*cssl); *cssl = NULL; -- 2.47.2