From 2602caa459a8c370b3d022e754088da905ef879c Mon Sep 17 00:00:00 2001 From: Christopher Wellons Date: Mon, 30 Dec 2019 13:11:02 -0500 Subject: [PATCH] Don't dereference NULL pointer on OOM Fixes #37. --- endlessh.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/endlessh.c b/endlessh.c index f2aae72..537a037 100644 --- a/endlessh.c +++ b/endlessh.c @@ -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); } } }