From 3419b088ffe531799bdb47b3ff3fce85c8b7569a Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 20 Mar 2008 16:26:59 +0200 Subject: [PATCH] Don't access freed memory. --HG-- branch : HEAD --- src/imap/imap-sync.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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) { -- 2.47.3