changeset 19517:d2ffe96b5286

imap: Fixed potential crash when logging about pending commands at logout.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Wed, 16 Dec 2015 11:59:41 +0200
parents c986b91115d7
children f1ec963e9436
files src/imap/imap-client.c
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap/imap-client.c	Wed Dec 16 11:29:36 2015 +0200
+++ b/src/imap/imap-client.c	Wed Dec 16 11:59:41 2015 +0200
@@ -279,6 +279,11 @@
 	str = t_str_new(128);
 	str_append(str, " (");
 	for (cmd = client->command_queue; cmd != NULL; cmd = cmd->next) {
+		if (cmd->name == NULL) {
+			/* (parts of a) tag were received, but not yet
+			   the command name */
+			continue;
+		}
 		str_append(str, cmd->name);
 		if (cmd->next != NULL)
 			str_append_c(str, ',');
@@ -287,6 +292,8 @@
 		bytes_out += cmd->bytes_out;
 		last_cmd = cmd;
 	}
+	if (str_len(str) <= 2)
+		return "";
 
 	cond = io_loop_find_fd_conditions(current_ioloop, client->fd_out);
 	if ((cond & (IO_READ | IO_WRITE)) == (IO_READ | IO_WRITE))