]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Don't access freed memory.
authorTimo Sirainen <tss@iki.fi>
Thu, 20 Mar 2008 14:26:59 +0000 (16:26 +0200)
committerTimo Sirainen <tss@iki.fi>
Thu, 20 Mar 2008 14:26:59 +0000 (16:26 +0200)
--HG--
branch : HEAD

src/imap/imap-sync.c

index d78a7d9b341d75e426601cb7992797eadea85227..13f2ff17881929380d91b73e8cb48c81797dc531 100644 (file)
@@ -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) {