From: JiashengJiang Date: Mon, 12 May 2025 13:59:02 +0000 (-0400) Subject: test/helpers/quictestlib.c: Use goto instead of return to avoid memory leak X-Git-Tag: openssl-3.6.0-alpha1~604 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de1e4989d564ea9a6d2960204806a1f3537419ad;p=thirdparty%2Fopenssl.git test/helpers/quictestlib.c: Use goto instead of return to avoid memory leak When TEST_ptr(*cssl) fails, bdata should be freed to avoid memory leak. Fixes: a55b689 ("Use reported short conn id len in qtestlib") Signed-off-by: JiashengJiang Reviewed-by: Matt Caswell Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/27599) --- diff --git a/test/helpers/quictestlib.c b/test/helpers/quictestlib.c index 166e102a2de..420d3b5acd5 100644 --- a/test/helpers/quictestlib.c +++ b/test/helpers/quictestlib.c @@ -164,11 +164,6 @@ int qtest_create_quic_objects(OSSL_LIB_CTX *libctx, SSL_CTX *clientctx, return 0; *qtserv = NULL; - if (*cssl == NULL) { - *cssl = SSL_new(clientctx); - if (!TEST_ptr(*cssl)) - return 0; - } if (fault != NULL) { *fault = OPENSSL_zalloc(sizeof(**fault)); @@ -177,6 +172,12 @@ int qtest_create_quic_objects(OSSL_LIB_CTX *libctx, SSL_CTX *clientctx, bdata->fault = *fault; } + if (*cssl == NULL) { + *cssl = SSL_new(clientctx); + if (!TEST_ptr(*cssl)) + goto err; + } + #ifndef OPENSSL_NO_SSL_TRACE if ((flags & QTEST_FLAG_CLIENT_TRACE) != 0) { tmpbio = BIO_new_fp(stdout, BIO_NOCLOSE);