]> granicus.if.org Git - neomutt/commitdiff
Avoid segfault when listing mailboxes on startup.
authorJohn Swinbank <john@swinbank.org>
Sun, 11 Sep 2016 00:15:42 +0000 (20:15 -0400)
committerRichard Russon <rich@flatcap.org>
Sun, 11 Sep 2016 00:25:37 +0000 (01:25 +0100)
When mutt is started with the -y flag, _mutt_select_file() is called while
CurrentFolder is a null pointer. If that's the case, we shouldn't try to use
it.

Closes: #137
browser.c

index 83d899443c1e3ae22f59b7f85338b8b4e203c7bc..23be9a02af61d4c851103def58cbe85747b5a019 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -1128,11 +1128,14 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num
        * This code is executed only when we list files, not when
        * we press up/down keys to navigate in a displayed list.
        *
+       * We only do this when CurrentFolder has been set (ie, not
+       * when listing folders on startup with "mutt -y").
+       *
        * This tracker is only used when browser_track is true,
        * meaning only with sort methods SUBJECT/DESC for now.
        */
-      if ((!LastDir[0]) ||
-           (mutt_strcmp (CurrentFolder, OldLastDir) != 0))
+      if (CurrentFolder && ((!LastDir[0]) ||
+           (mutt_strcmp (CurrentFolder, OldLastDir) != 0)))
       {
         mutt_browser_select_dir (CurrentFolder);
       }