From c7722f2b97724612f3ef5ce1a8cf324d8d799a3c Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Fri, 26 Jun 2015 21:29:54 +0100 Subject: [PATCH] Guard against closing clients in a couple of places. In particular, not guarding in flushWrites() meant that we could end up trying to write to an uninitialized writer (where writer->service == c->service == NULL) and crashing. --- net_io.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net_io.c b/net_io.c index 6929ba9..9f334dc 100644 --- a/net_io.c +++ b/net_io.c @@ -273,6 +273,8 @@ static void flushWrites(struct net_writer *writer) { struct client *c; for (c = Modes.clients; c; c = c->next) { + if (!c->service) + continue; if (c->service == writer->service) { #ifndef _WIN32 int nwritten = write(c->fd, writer->data, writer->dataUsed); @@ -1662,6 +1664,8 @@ void modesNetPeriodicWork(void) { // Read from clients for (c = Modes.clients; c; c = c->next) { + if (!c->service) + continue; if (c->service->read_handler) modesReadFromClient(c); }