From: Timo Sirainen Date: Mon, 25 Dec 2017 16:24:35 +0000 (+0200) Subject: lib-storage: mail_storage_set_index_error() - handle NULL index error X-Git-Tag: 2.2.34~149 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0c58d70856f26b64f49b116745b8565f100f4237;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: mail_storage_set_index_error() - handle NULL index error 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().) --- diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index b93935b053..6dca896690 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -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); }