From: Kevin McCarthy Date: Fri, 5 May 2017 20:55:31 +0000 (-0700) Subject: Don't modify LastFolder/CurrentFolder upon aborting a change folder operation. X-Git-Tag: mutt-1-8-3-rel~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3908c4d93b907ed0c21bf4b36b99ee960b0213bc;p=mutt Don't modify LastFolder/CurrentFolder upon aborting a change folder operation. Set LastFolder and CurrentFolder after mx_close_mailbox() has successfully completed. Otherwise, if the close is aborted, they will have incorrect values. --- diff --git a/curs_main.c b/curs_main.c index 43417188..a474d248 100644 --- a/curs_main.c +++ b/curs_main.c @@ -1238,7 +1238,6 @@ int mutt_index_menu (void) mutt_error (_("%s is not a mailbox."), buf); break; } - mutt_str_replace (&CurrentFolder, buf); /* keepalive failure in mutt_enter_fname may kill connection. #3028 */ if (Context && !Context->path) @@ -1247,13 +1246,14 @@ int mutt_index_menu (void) if (Context) { int check; + char *new_last_folder; #ifdef USE_COMPRESSED if (Context->compress_info && Context->realpath) - mutt_str_replace (&LastFolder, Context->realpath); + new_last_folder = safe_strdup (Context->realpath); else #endif - mutt_str_replace (&LastFolder, Context->path); + new_last_folder = safe_strdup (Context->path); oldcount = Context ? Context->msgcount : 0; if ((check = mx_close_mailbox (Context, &index_hint)) != 0) @@ -1261,12 +1261,16 @@ int mutt_index_menu (void) if (check == MUTT_NEW_MAIL || check == MUTT_REOPENED) update_index (menu, Context, check, oldcount, index_hint); + FREE (&new_last_folder); set_option (OPTSEARCHINVALID); menu->redraw = REDRAW_INDEX | REDRAW_STATUS; break; } FREE (&Context); + FREE (&LastFolder); + LastFolder = new_last_folder; } + mutt_str_replace (&CurrentFolder, buf); mutt_sleep (0);