Commit 117dc48fd5 for openssl.org
commit 117dc48fd587099dfb2d0fc107c84f0e359284ad
Author: 609bob <1850029304@qq.com>
Date: Fri Dec 19 10:27:06 2025 +0800
bss_acpt.c: Free strings returned from previous BIO_ADDR_hostname_string() calls
CLA: trivial
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29452)
diff --git a/crypto/bio/bss_acpt.c b/crypto/bio/bss_acpt.c
index 80e62df825..c399357a3c 100644
--- a/crypto/bio/bss_acpt.c
+++ b/crypto/bio/bss_acpt.c
@@ -266,6 +266,9 @@ static int acpt_state(BIO *b, BIO_ACCEPT *c)
}
}
+ /* Free old values before assigning new ones to prevent memory leak */
+ OPENSSL_free(c->cache_accepting_name);
+ OPENSSL_free(c->cache_accepting_serv);
c->cache_accepting_name = BIO_ADDR_hostname_string(&c->cache_accepting_addr, 1);
c->cache_accepting_serv = BIO_ADDR_service_string(&c->cache_accepting_addr, 1);
c->state = ACPT_S_ACCEPT;