Fix: Add free to avoid memory leak.

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Paul Yang <paulyang.inf@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28289)
This commit is contained in:
Nachel72 2025-08-17 14:08:38 +08:00 committed by Neil Horman
parent 045a158e61
commit f9afb3a07e
4 changed files with 16 additions and 4 deletions

View File

@ -53,7 +53,8 @@ int main(int argc, char *argv[])
{
char *port = NULL;
BIO *in = NULL;
BIO *ssl_bio, *tmp;
BIO *ssl_bio = NULL;
BIO *tmp;
SSL_CTX *ctx;
char buf[512];
int ret = EXIT_FAILURE, i;
@ -83,6 +84,7 @@ int main(int argc, char *argv[])
* Basically it means the SSL BIO will be automatically setup
*/
BIO_set_accept_bios(in, ssl_bio);
ssl_bio = NULL;
/* Arrange to leave server loop on interrupt */
sigsetup();
@ -121,5 +123,6 @@ int main(int argc, char *argv[])
if (ret != EXIT_SUCCESS)
ERR_print_errors_fp(stderr);
BIO_free(in);
BIO_free_all(ssl_bio);
return ret;
}

View File

@ -23,7 +23,8 @@
int main(int argc, char *argv[])
{
char *port = "*:4433";
BIO *ssl_bio, *tmp;
BIO *ssl_bio = NULL;
BIO *tmp;
SSL_CTX *ctx;
SSL_CONF_CTX *cctx;
char buf[512];
@ -105,6 +106,7 @@ int main(int argc, char *argv[])
* Basically it means the SSL BIO will be automatically setup
*/
BIO_set_accept_bios(in, ssl_bio);
ssl_bio = NULL;
again:
/*
@ -140,5 +142,6 @@ int main(int argc, char *argv[])
if (ret != EXIT_SUCCESS)
ERR_print_errors_fp(stderr);
BIO_free(in);
BIO_free_all(ssl_bio);
return ret;
}

View File

@ -24,7 +24,8 @@ int main(int argc, char *argv[])
unsigned char buf[512];
char *port = "*:4433";
BIO *in = NULL;
BIO *ssl_bio, *tmp;
BIO *ssl_bio = NULL;
BIO *tmp;
SSL_CTX *ctx;
int ret = EXIT_FAILURE, i;
@ -52,6 +53,7 @@ int main(int argc, char *argv[])
* Basically it means the SSL BIO will be automatically setup
*/
BIO_set_accept_bios(in, ssl_bio);
ssl_bio = NULL;
again:
/*
@ -90,5 +92,6 @@ int main(int argc, char *argv[])
if (ret != EXIT_SUCCESS)
ERR_print_errors_fp(stderr);
BIO_free(in);
BIO_free_all(ssl_bio);
return ret;
}

View File

@ -25,7 +25,8 @@ int main(int argc, char *argv[])
{
char *port = "*:4433";
BIO *in = NULL;
BIO *ssl_bio, *tmp;
BIO *ssl_bio = NULL;
BIO *tmp;
SSL_CTX *ctx;
SSL_CONF_CTX *cctx = NULL;
CONF *conf = NULL;
@ -97,6 +98,7 @@ int main(int argc, char *argv[])
* Basically it means the SSL BIO will be automatically setup
*/
BIO_set_accept_bios(in, ssl_bio);
ssl_bio = NULL;
again:
/*
@ -135,5 +137,6 @@ int main(int argc, char *argv[])
if (ret != EXIT_SUCCESS)
ERR_print_errors_fp(stderr);
BIO_free(in);
BIO_free_all(ssl_bio);
return ret;
}