From df0f2759220f825efe1a77eae9e658fe37cc89c3 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Wed, 27 Apr 2016 12:46:51 +0100 Subject: [PATCH] Close the accept socket on error When setting an accepted socket for non-blocking, if the operation fails make sure we close the accepted socket. Reviewed-by: Richard Levitte --- crypto/bio/b_sock2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crypto/bio/b_sock2.c b/crypto/bio/b_sock2.c index 9f092fc073..e876e07f1b 100644 --- a/crypto/bio/b_sock2.c +++ b/crypto/bio/b_sock2.c @@ -294,8 +294,10 @@ int BIO_accept_ex(int accept_sock, BIO_ADDR *addr_, int options) return INVALID_SOCKET; } - if (!BIO_socket_nbio(accepted_sock, (options & BIO_SOCK_NONBLOCK) != 0)) + if (!BIO_socket_nbio(accepted_sock, (options & BIO_SOCK_NONBLOCK) != 0)) { + closesocket(accepted_sock); return INVALID_SOCKET; + } return accepted_sock; } -- 2.25.1