summaryrefslogtreecommitdiff
path: root/lib/libcrypto/bio
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2014-04-23 20:22:38 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2014-04-23 20:22:38 +0000
commit5fa0406c9126206a423231b81b6a19eeec24af1e (patch)
treea7cf9a9b8b919314e292dd272b9152f8f198c858 /lib/libcrypto/bio
parent5dcd1870e1bf596d26a5c4415f176953dd06e765 (diff)
close socket in failure cases too
Diffstat (limited to 'lib/libcrypto/bio')
-rw-r--r--lib/libcrypto/bio/b_sock.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/libcrypto/bio/b_sock.c b/lib/libcrypto/bio/b_sock.c
index a7791b39e2e..e5f42398df6 100644
--- a/lib/libcrypto/bio/b_sock.c
+++ b/lib/libcrypto/bio/b_sock.c
@@ -535,6 +535,7 @@ BIO_accept(int sock, char **addr)
if (p) {
*p = '\0';
if (!(tmp = realloc(p, nl))) {
+ close(ret);
ret = -1;
free(p);
*addr = NULL;
@@ -546,6 +547,7 @@ BIO_accept(int sock, char **addr)
p = malloc(nl);
}
if (p == NULL) {
+ close(ret);
ret = -1;
BIOerr(BIO_F_BIO_ACCEPT, ERR_R_MALLOC_FAILURE);
goto end;
@@ -561,6 +563,7 @@ BIO_accept(int sock, char **addr)
port = ntohs(sa.from.sa_in.sin_port);
if (*addr == NULL) {
if ((p = malloc(24)) == NULL) {
+ close(ret);
ret = -1;
BIOerr(BIO_F_BIO_ACCEPT, ERR_R_MALLOC_FAILURE);
goto end;