From aeffe74a27fbe83f9f3da2672e2b62efe1255bf0 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Wed, 18 Jan 2017 10:48:50 +0100 Subject: [PATCH] Avoid calling close when polling a UDP peer without socket (cherry picked from commit e4b9b37ccf8495be674bc15cf0bf9d76fe94e6be) --- drivers/unix/packet_peer_udp_posix.cpp | 4 ++++ platform/windows/packet_peer_udp_winsock.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/drivers/unix/packet_peer_udp_posix.cpp b/drivers/unix/packet_peer_udp_posix.cpp index 04be55d6c6a..faabe902f9c 100644 --- a/drivers/unix/packet_peer_udp_posix.cpp +++ b/drivers/unix/packet_peer_udp_posix.cpp @@ -154,6 +154,10 @@ Error PacketPeerUDPPosix::wait() { Error PacketPeerUDPPosix::_poll(bool p_wait) { + if (sockfd == -1) { + return FAILED; + } + struct sockaddr_storage from = { 0 }; socklen_t len = sizeof(struct sockaddr_storage); int ret; diff --git a/platform/windows/packet_peer_udp_winsock.cpp b/platform/windows/packet_peer_udp_winsock.cpp index d8707709f52..1dc23fcab95 100644 --- a/platform/windows/packet_peer_udp_winsock.cpp +++ b/platform/windows/packet_peer_udp_winsock.cpp @@ -149,6 +149,10 @@ Error PacketPeerUDPWinsock::wait() { } Error PacketPeerUDPWinsock::_poll(bool p_wait) { + if (sockfd == -1) { + return FAILED; + } + _set_blocking(p_wait); struct sockaddr_storage from = { 0 };