summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>2021-09-29 10:46:23 +0200
committerTomas Mraz <tomas@openssl.org>2021-10-04 10:55:39 +0200
commit2342d9b650ed3dafd65b7edadbe805e04a4966ba (patch)
treed73511d2ab0517ee2c62adfd1b56b99546dae254 /apps
parentdce910af3bb135bd6d7c5a4cc512043b3ad4acc1 (diff)
apps/lib/s_socket.c: Fix mem leak on host name in init_client()
Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16688)
Diffstat (limited to 'apps')
-rw-r--r--apps/lib/s_socket.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/apps/lib/s_socket.c b/apps/lib/s_socket.c
index 1dd30ac724..4e262e681d 100644
--- a/apps/lib/s_socket.c
+++ b/apps/lib/s_socket.c
@@ -82,6 +82,7 @@ int init_client(int *sock, const char *host, const char *port,
BIO_ADDRINFO *bindaddr = NULL;
const BIO_ADDRINFO *ai = NULL;
const BIO_ADDRINFO *bi = NULL;
+ char *hostname = NULL;
int found = 0;
int ret;
@@ -172,7 +173,9 @@ int init_client(int *sock, const char *host, const char *port,
break;
}
- BIO_printf(bio_out, "Connecting to %s\n", BIO_ADDR_hostname_string(BIO_ADDRINFO_address(ai), 1));
+ hostname = BIO_ADDR_hostname_string(BIO_ADDRINFO_address(ai), 1);
+ BIO_printf(bio_out, "Connecting to %s\n", hostname);
+ OPENSSL_free(hostname);
if (*sock == INVALID_SOCKET) {
if (bindaddr != NULL && !found) {