Fix a crash bug if c-ares is enabled

CSocket sometimes calls our select() wrapper with writeds == NULL and we didn't
handle this case at all which lead to a NULL pointer dereference.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1586 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2009-08-05 19:35:09 +00:00
parent 4fd1b09f7f
commit f8c78f83ef

View File

@@ -64,6 +64,14 @@ CSockManager::~CSockManager() {
int CSockManager::Select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
{
int ret;
fd_set tmp;
// Csocket sometimes can use NULL for exceptfds and c-ares doesn't like NULLs
if (writefds == NULL)
{
writefds = &tmp;
FD_ZERO(writefds);
}
// We assume that nfds is already the max. number of sockets allowed by
// the OS, so we don't need to update it here.