Merge pull request #1016 from devnexen/netsocket_desc_leaks

network close descriptors on socket creation failure.
This commit is contained in:
Yamagi 2023-06-05 19:16:23 +02:00 committed by GitHub
commit 4f04e7857a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -864,6 +864,7 @@ NET_Socket(char *net_interface, int port, netsrc_t type, int family)
if (ioctl(newsocket, FIONBIO, (char *)&_true) == -1)
{
Com_Printf("NET_Socket: ioctl FIONBIO: %s\n", strerror(errno));
close(newsocket);
continue;
}
@ -876,6 +877,7 @@ NET_Socket(char *net_interface, int port, netsrc_t type, int family)
Com_Printf("ERROR: NET_Socket: setsockopt SO_BROADCAST:%s\n",
NET_ErrorString());
freeaddrinfo(res);
close(newsocket);
return 0;
}
}
@ -887,6 +889,7 @@ NET_Socket(char *net_interface, int port, netsrc_t type, int family)
Com_Printf("ERROR: NET_Socket: setsockopt SO_REUSEADDR:%s\n",
NET_ErrorString());
freeaddrinfo(res);
close(newsocket);
return 0;
}
@ -908,6 +911,7 @@ NET_Socket(char *net_interface, int port, netsrc_t type, int family)
if (ai == NULL)
{
close(newsocket);
return 0;
}