changeset 20513:56666f12cfb7

pop3c: Fixed crash in syncing when local indexes existed but UIDL wasn't cached.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Mon, 11 Jul 2016 11:40:41 +0300
parents 9f7115042632
children fe9ed1aa41ad
files src/lib-storage/index/pop3c/pop3c-sync.c
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/pop3c/pop3c-sync.c	Mon Jul 11 10:22:06 2016 +0300
+++ b/src/lib-storage/index/pop3c/pop3c-sync.c	Mon Jul 11 11:40:41 2016 +0300
@@ -148,11 +148,10 @@
 	for (seq = 1; seq <= messages_count; seq++) {
 		str_truncate(str, 0);
 		if (mail_cache_lookup_field(cache_view, str, seq,
-					    cache_idx) > 0) {
-			msg.seq = seq;
+					    cache_idx) > 0)
 			msg.uidl = p_strdup(pool, str_c(str));
-			array_idx_set(local_msgs, seq-1, &msg);
-		}
+		msg.seq = seq;
+		array_idx_set(local_msgs, seq-1, &msg);
 	}
 }
 
@@ -231,12 +230,13 @@
 
 		if (lidx >= lcount)
 			ret = 1;
-		else if (ridx >= rcount)
+		else if (ridx >= rcount || lmsg[lidx].uidl == NULL)
 			ret = -1;
 		else
 			ret = strcmp(lmsg[lidx].uidl, rmsg[ridx].uidl);
 		if (ret < 0) {
-			/* message expunged in remote */
+			/* message expunged in remote, or we didn't have a
+			   local message's UIDL in cache. */
 			mail_index_expunge(sync_trans, lseq);
 			lidx++;
 		} else if (ret > 0) {