Don't dereference NULL pointer on OOM

Fixes #37.
This commit is contained in:
Christopher Wellons 2019-12-30 13:11:02 -05:00
parent 715f30c3a7
commit 2602caa459

View File

@ -790,11 +790,12 @@ main(int argc, char **argv)
if (!client) {
fprintf(stderr, "endlessh: warning: out of memory\n");
close(fd);
} else {
fifo_append(fifo, client);
logmsg(LOG_INFO, "ACCEPT host=%s port=%d fd=%d n=%d/%d",
client->ipaddr, client->port, client->fd,
fifo->length, config.max_clients);
}
fifo_append(fifo, client);
logmsg(LOG_INFO, "ACCEPT host=%s port=%d fd=%d n=%d/%d",
client->ipaddr, client->port, client->fd,
fifo->length, config.max_clients);
}
}
}