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,7 +790,7 @@ main(int argc, char **argv)
if (!client) { if (!client) {
fprintf(stderr, "endlessh: warning: out of memory\n"); fprintf(stderr, "endlessh: warning: out of memory\n");
close(fd); close(fd);
} } else {
fifo_append(fifo, client); fifo_append(fifo, client);
logmsg(LOG_INFO, "ACCEPT host=%s port=%d fd=%d n=%d/%d", logmsg(LOG_INFO, "ACCEPT host=%s port=%d fd=%d n=%d/%d",
client->ipaddr, client->port, client->fd, client->ipaddr, client->port, client->fd,
@@ -798,6 +798,7 @@ main(int argc, char **argv)
} }
} }
} }
}
fifo_destroy(fifo); fifo_destroy(fifo);
statistics_log_totals(0); statistics_log_totals(0);