From: Timo Sirainen Date: Thu, 20 Mar 2008 14:26:59 +0000 (+0200) Subject: Don't access freed memory. X-Git-Tag: 1.1.rc4~17 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3419b088ffe531799bdb47b3ff3fce85c8b7569a;p=thirdparty%2Fdovecot%2Fcore.git Don't access freed memory. --HG-- branch : HEAD --- diff --git a/src/imap/imap-sync.c b/src/imap/imap-sync.c index d78a7d9b34..13f2ff1788 100644 --- a/src/imap/imap-sync.c +++ b/src/imap/imap-sync.c @@ -210,7 +210,7 @@ static bool cmd_finish_sync(struct client_command_context *cmd) static bool cmd_sync_continue(struct client_command_context *sync_cmd) { - struct client_command_context *cmd; + struct client_command_context *cmd, *next; struct client *client = sync_cmd->client; struct imap_sync_context *ctx = sync_cmd->context; int ret; @@ -230,7 +230,9 @@ static bool cmd_sync_continue(struct client_command_context *sync_cmd) sync_cmd->context = NULL; /* finish all commands that waited for this sync */ - for (cmd = client->command_queue; cmd != NULL; cmd = cmd->next) { + for (cmd = client->command_queue; cmd != NULL; cmd = next) { + next = cmd->next; + if (cmd->state == CLIENT_COMMAND_STATE_WAIT_SYNC && cmd != sync_cmd && cmd->sync->counter+1 == client->sync_counter) {