Browse Source

Avoid calling close when polling a UDP peer without socket

Fabio Alessandrelli 8 years ago
parent
commit
e4b9b37ccf

+ 4 - 0
drivers/unix/packet_peer_udp_posix.cpp

@@ -157,6 +157,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;

+ 3 - 0
platform/windows/packet_peer_udp_winsock.cpp

@@ -152,6 +152,9 @@ Error PacketPeerUDPWinsock::wait() {
 }
 Error PacketPeerUDPWinsock::_poll(bool p_wait) {
 
+	if (sockfd==-1) {
+		return FAILED;
+	}
 
 	_set_blocking(p_wait);