From 86dac8c979c2bf30eef9a2d513f56c2627e06691 Mon Sep 17 00:00:00 2001 From: Themaister Date: Thu, 12 Jan 2012 09:21:33 +0100 Subject: [PATCH] Make sure sockets are not closed twice on error. --- netplay.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/netplay.c b/netplay.c index fd43730a6b..0db91b741f 100644 --- a/netplay.c +++ b/netplay.c @@ -237,6 +237,7 @@ static bool init_tcp_socket(netplay_t *handle, const char *server, uint16_t port { SSNES_ERR("Failed to connect to server.\n"); close(handle->fd); + handle->fd = -1; freeaddrinfo(res); return false; } @@ -251,6 +252,7 @@ static bool init_tcp_socket(netplay_t *handle, const char *server, uint16_t port { SSNES_ERR("Failed to bind socket.\n"); close(handle->fd); + handle->fd = -1; freeaddrinfo(res); return false; } @@ -265,6 +267,7 @@ static bool init_tcp_socket(netplay_t *handle, const char *server, uint16_t port { SSNES_ERR("Failed to bind socket.\n"); close(handle->fd); + handle->fd = -1; freeaddrinfo(res); return false; } @@ -276,6 +279,7 @@ static bool init_tcp_socket(netplay_t *handle, const char *server, uint16_t port { SSNES_ERR("Failed to accept socket.\n"); close(handle->fd); + handle->fd = -1; freeaddrinfo(res); return false; } @@ -328,6 +332,7 @@ static bool init_udp_socket(netplay_t *handle, const char *server, uint16_t port { SSNES_ERR("Failed to bind socket.\n"); close(handle->udp_fd); + handle->udp_fd = -1; } freeaddrinfo(handle->addr);