ctdlsh: don't crash on the mailq command if the queue is empty.
authorArt Cancro <ajc@citadel.org>
Sun, 19 Nov 2017 21:32:47 +0000 (16:32 -0500)
committerArt Cancro <ajc@citadel.org>
Sun, 19 Nov 2017 21:32:47 +0000 (16:32 -0500)
ctdlsh/mailq.c

index 772c242..d6ed794 100644 (file)
@@ -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);
 }