Skip to content

Commit

Permalink
imap: Avoid wrongly assert-crashing in client_check_command_hangs()
Browse files Browse the repository at this point in the history
Fixes assert:

Panic: file imap-client.c: line 837 (client_check_command_hangs): assertion failed: (client->io != NULL)
  • Loading branch information
sirainen committed Sep 9, 2016
1 parent 853992a commit 980f2d5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/imap/imap-client.c
Expand Up @@ -840,7 +840,14 @@ static void client_check_command_hangs(struct client *client)
for (cmd = client->command_queue; cmd != NULL; cmd = cmd->next) {
switch (cmd->state) {
case CLIENT_COMMAND_STATE_WAIT_INPUT:
i_assert(client->io != NULL);
/* We need to be reading input for this command.
However, if there is already an output lock for
another command we'll wait for it to finish first.
This is needed because if there are any literals
we'd need to send "+ OK" responses. */
i_assert(client->io != NULL ||
(client->output_cmd_lock != NULL &&
client->output_cmd_lock != client->input_lock));
unfinished_count++;
break;
case CLIENT_COMMAND_STATE_WAIT_OUTPUT:
Expand Down Expand Up @@ -1043,6 +1050,8 @@ static bool client_handle_next_command(struct client *client, bool *remove_io_r)
if (client->input_lock != NULL) {
if (client->input_lock->state ==
CLIENT_COMMAND_STATE_WAIT_UNAMBIGUITY ||
/* we can't send literal "+ OK" replies if output is
locked by another command. */
(client->output_cmd_lock != NULL &&
client->output_cmd_lock != client->input_lock)) {
*remove_io_r = TRUE;
Expand Down

0 comments on commit 980f2d5

Please sign in to comment.