]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Assert if mail_index_transaction_sort_appends() sees any uid==0
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 14 Nov 2016 16:22:53 +0000 (17:22 +0100)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 18 Nov 2016 11:55:48 +0000 (13:55 +0200)
Every mail must have an UID at this stage.

src/lib-index/mail-index-transaction-sort-appends.c

index 2b8c66cf5cacb6300b5681629c8062b4870dd8df..f058659fbb8d7c6d85dbb4e4016687360bbf6f72 100644 (file)
@@ -131,10 +131,12 @@ void mail_index_transaction_sort_appends(struct mail_index_transaction *t)
 
        if (!array_is_created(&t->appends))
                return;
+       recs = array_get_modifiable(&t->appends, &count);
+       i_assert(count > 0);
+
        if (!t->appends_nonsorted) {
+               i_assert(recs[0].uid != 0);
 #ifdef DEBUG
-               recs = array_get_modifiable(&t->appends, &count);
-               i_assert(count > 0);
                for (i = 1; i < count; i++)
                        i_assert(recs[i-1].uid < recs[i].uid);
 #endif
@@ -142,11 +144,9 @@ void mail_index_transaction_sort_appends(struct mail_index_transaction *t)
        }
 
        /* first make a copy of the UIDs and map them to sequences */
-       recs = array_get_modifiable(&t->appends, &count);
-       i_assert(count > 0);
-
        new_uid_map = i_new(struct uid_map, count);
        for (i = 0; i < count; i++) {
+               i_assert(recs[i].uid != 0);
                new_uid_map[i].idx = i;
                new_uid_map[i].uid = recs[i].uid;
        }