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.
This commit is contained in:
Oliver Jowett 2015-06-26 21:29:54 +01:00
parent 8d1df036ae
commit c7722f2b97

View file

@ -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);
}