From e24e40657f7318248356699e8ec99cb746450708 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Mon, 5 Feb 2001 09:15:09 +0000 Subject: [PATCH] Fix a memory leak in BIO_get_accept_socket(). This leak was small and only happened when the port number wasn't parsable ot the host wasn't possible to convert to an IP address. Contributed by Niko Baric --- crypto/bio/b_sock.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crypto/bio/b_sock.c b/crypto/bio/b_sock.c index da2ff2900f..701a04bdd9 100644 --- a/crypto/bio/b_sock.c +++ b/crypto/bio/b_sock.c @@ -519,10 +519,10 @@ int BIO_get_accept_socket(char *host, int bind_mode) { int ret=0; struct sockaddr_in server,client; - int s= -1,cs; + int s=INVALID_SOCKET,cs; unsigned char ip[4]; unsigned short port; - char *str,*e; + char *str=NULL,*e; const char *h,*p; unsigned long l; int err_num; @@ -553,7 +553,7 @@ int BIO_get_accept_socket(char *host, int bind_mode) h="*"; } - if (!BIO_get_port(p,&port)) return(INVALID_SOCKET); + if (!BIO_get_port(p,&port)) goto err; memset((char *)&server,0,sizeof(server)); server.sin_family=AF_INET; @@ -563,7 +563,7 @@ int BIO_get_accept_socket(char *host, int bind_mode) server.sin_addr.s_addr=INADDR_ANY; else { - if (!BIO_get_host_ip(h,&(ip[0]))) return(INVALID_SOCKET); + if (!BIO_get_host_ip(h,&(ip[0]))) goto err; l=(unsigned long) ((unsigned long)ip[0]<<24L)| ((unsigned long)ip[1]<<16L)| -- 2.34.1