]> granicus.if.org Git - neomutt/commitdiff
imap: ensure we can't delete the current selected mailbox
authorMehdi Abaakouk <sileht@sileht.net>
Fri, 16 Nov 2018 09:00:23 +0000 (10:00 +0100)
committerRichard Russon <rich@flatcap.org>
Fri, 16 Nov 2018 11:15:34 +0000 (11:15 +0000)
Closes #1417

browser.c

index fbd7d8fde25373d72c26d289b6ab3767f197f5ce..bc153c01716a5985e8c6bf16f99c770f46ee2f90 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -1685,6 +1685,15 @@ void mutt_select_file(char *file, size_t filelen, int flags, char ***files, int
           char msg[SHORT_STRING];
           int nentry = menu->current;
 
+          // TODO(sileht): It could be better to select INBOX instead. But I
+          // don't want to manipulate Context/AllMailboxes/mailbox->account here for now.
+          // Let's just protect neomutt against crash for now. #1417
+          if (mutt_str_strcmp(Context->mailbox->path, state.entry[nentry].name) == 0)
+          {
+            mutt_error(_("Can't delete currently selected mailbox"));
+            break;
+          }
+
           snprintf(msg, sizeof(msg), _("Really delete mailbox \"%s\"?"),
                    state.entry[nentry].name);
           if (mutt_yesorno(msg, MUTT_NO) == MUTT_YES)