]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: mailbox_list_get_last_error() - Handle unexpected situations better
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 24 Jan 2020 11:50:50 +0000 (13:50 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 15 Jan 2021 09:27:12 +0000 (09:27 +0000)
Change the logic to be similar as in mail_storage_get_last_error() if the
mail_error or error_string unexpectedly isn't set.

src/lib-storage/mailbox-list.c

index b9573cb90c0df09dbeb628826bb124d3a66a1ee1..4ac22a2882fee2c6b7c39c7036b0ca58cfc11b56 100644 (file)
@@ -1908,11 +1908,23 @@ bool mailbox_list_try_get_absolute_path(struct mailbox_list *list,
 const char *mailbox_list_get_last_error(struct mailbox_list *list,
                                        enum mail_error *error_r)
 {
+       if (list->error == MAIL_ERROR_NONE) {
+               if (error_r != NULL)
+                       *error_r = MAIL_ERROR_TEMP;
+               return list->error_string != NULL ? list->error_string :
+                       "BUG: Unknown internal list error";
+       }
+
+       if (list->error_string == NULL) {
+               /* This shouldn't happen.. */
+               list->error_string =
+                       i_strdup_printf("BUG: Unknown 0x%x list error",
+                                       list->error);
+       }
+
        if (error_r != NULL)
                *error_r = list->error;
-
-       return list->error_string != NULL ? list->error_string :
-               "Unknown internal list error";
+       return list->error_string;
 }
 
 enum mail_error mailbox_list_get_last_mail_error(struct mailbox_list *list)