From 7dd91af4568d1247e32e33319a875c274d6c7ca5 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Mon, 21 May 2012 16:42:26 +0100 Subject: [PATCH] Fix off-by-one in uidset handling for fetches When we get to the end of the for() loop processing the uidset, the index variable is one *more* than the last item. That's how for() loops in C work. But when we break out of the middle because we are limiting the batch size, we were forgetting to do the same and we were storing the index of the last item that we'd already fetched. This was causing us to re-fetch the last message of one batch, as the first message of the next batch. Mostly harmless, but spotted and fixed as part of bug 667725. --- camel/camel-imapx-server.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/camel/camel-imapx-server.c b/camel/camel-imapx-server.c index 3556e62..d66e81c 100644 --- a/camel/camel-imapx-server.c +++ b/camel/camel-imapx-server.c @@ -1372,7 +1372,7 @@ imapx_untagged (CamelIMAPXServer *is, g_return_val_if_fail (data != NULL, FALSE); min = data->last_index; - max = data->index; + max = data->index - 1; /* array is sorted, so use a binary search */ do { @@ -3468,7 +3468,7 @@ imapx_command_copy_messages_step_start (CamelIMAPXServer *is, res = imapx_uidset_add (&data->uidset, ic, uid); if (res == 1) { camel_imapx_command_add (ic, " %f", data->dest); - data->index = i; + data->index = i + 1; imapx_command_queue (is, ic); return; } @@ -3758,7 +3758,7 @@ imapx_command_step_fetch_done (CamelIMAPXServer *is, res = imapx_uidset_add (&data->uidset, ic, r->uid); if (res == 1) { camel_imapx_command_add (ic, " (RFC822.SIZE RFC822.HEADER)"); - data->index = i; + data->index = i + 1; imapx_command_queue (is, ic); return TRUE; } -- 2.7.4