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 772c242302e7a060fc8acbf6d65032267db5a0b7..d6ed794aaed771b614afa180c11e73dc36e47c2b 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);
 }