From f8c78f83efd202fd5cabc0e7a8013ce07a2bdd27 Mon Sep 17 00:00:00 2001 From: psychon Date: Wed, 5 Aug 2009 19:35:09 +0000 Subject: [PATCH] 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 --- Socket.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Socket.cpp b/Socket.cpp index c771fdb0..7459877b 100644 --- a/Socket.cpp +++ b/Socket.cpp @@ -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.