]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: mail_storage_set_index_error() - handle NULL index error
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 25 Dec 2017 16:24:35 +0000 (18:24 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Mon, 15 Jan 2018 09:18:34 +0000 (11:18 +0200)
This avoids assert-crashing later on in mail*_get_last_internal_error().

This could potentially be an assert instead of setting it as "BUG", but
it looks like there are various code paths in lib-index that return -1
without setting an error. (That's to avoid duplicate error logging,
although it could now be fixed with mail_index_set_error_nolog().)

src/lib-storage/mail-storage.c

index b93935b05306e055a0c1e07fb64b456c419a82a2..6dca896690479c46c3dc63b432f8dd6b5e537fdd 100644 (file)
@@ -616,10 +616,14 @@ void mailbox_set_index_error(struct mailbox *box)
 void mail_storage_set_index_error(struct mail_storage *storage,
                                  struct mail_index *index)
 {
+       const char *index_error;
+
        mail_storage_set_internal_error(storage);
        /* use the lib-index's error as our internal error string */
-       storage->last_internal_error =
-               i_strdup(mail_index_get_error_message(index));
+       index_error = mail_index_get_error_message(index);
+       if (index_error == NULL)
+               index_error = "BUG: Unknown internal index error";
+       storage->last_internal_error = i_strdup(index_error);
        storage->last_error_is_internal = TRUE;
        mail_index_reset_error(index);
 }