]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
pop3c: Fixed crash in syncing when local indexes existed but UIDL wasn't cached.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 11 Jul 2016 08:40:41 +0000 (11:40 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 11 Jul 2016 14:38:54 +0000 (17:38 +0300)
src/lib-storage/index/pop3c/pop3c-sync.c

index 8acbc79532b00cd3a74f10852bf1dafa8b9e674c..ac2ecc199923a45484282d822e99d84103af863a 100644 (file)
@@ -148,11 +148,10 @@ pop3c_get_local_msgs(pool_t pool, ARRAY_TYPE(pop3c_sync_msg) *local_msgs,
        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 @@ pop3c_sync_messages(struct pop3c_mailbox *mbox,
 
                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) {