]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: mail_index_update_keywords() - don't assert if adding/removing 0 keywords
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 27 Apr 2017 09:50:13 +0000 (12:50 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 27 Apr 2017 09:50:13 +0000 (12:50 +0300)
Although it would be nice for the caller to check it, it's easier to do
here. It's mainly a problem with mailbox_keywords_create_valid() that may
unexpectedly create empty keywords.

src/lib-index/mail-index-transaction-update.c

index 9fbeca447502e90862c2960086d1710f5a30dc84..8b0047af1eab05780d0e31a5b13e9c16fc1f76b3 100644 (file)
@@ -1156,9 +1156,11 @@ void mail_index_update_keywords(struct mail_index_transaction *t, uint32_t seq,
        i_assert(seq > 0 &&
                 (seq <= mail_index_view_get_messages_count(t->view) ||
                  seq <= t->last_new_seq));
-       i_assert(keywords->count > 0 || modify_type == MODIFY_REPLACE);
        i_assert(keywords->index == t->view->index);
 
+       if (keywords->count == 0 && modify_type != MODIFY_REPLACE)
+               return;
+
        update_minmax_flagupdate_seq(t, seq, seq);
 
        if (!array_is_created(&t->keyword_updates)) {