From 6a82444d499be104e019899b9bdc8a14ad0cbd0f Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sun, 19 Nov 2017 16:32:47 -0500 Subject: [PATCH] ctdlsh: don't crash on the mailq command if the queue is empty. --- ctdlsh/mailq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ctdlsh/mailq.c b/ctdlsh/mailq.c index 772c24230..d6ed794aa 100644 --- a/ctdlsh/mailq.c +++ b/ctdlsh/mailq.c @@ -42,7 +42,7 @@ void mailq_show_this_queue_entry(StrBuf *MsgText) { int cmd_mailq(int server_socket, char *cmdbuf) { char buf[1024]; - long *msgs; + long *msgs = NULL; int num_msgs = 0; int num_alloc = 0; int i; @@ -91,7 +91,9 @@ int cmd_mailq(int server_socket, char *cmdbuf) { } } - free(msgs); + if (msgs != NULL) { + free(msgs); + } FreeStrBuf(&MsgText); return(cmdret_ok); } -- 2.39.2