]> granicus.if.org Git - neomutt/commitdiff
fix browser attach
authorRichard Russon <rich@flatcap.org>
Mon, 15 Jul 2019 16:24:40 +0000 (17:24 +0100)
committerRichard Russon <rich@flatcap.org>
Mon, 15 Jul 2019 16:24:50 +0000 (17:24 +0100)
browser.c

index aac624855d9e538b25770a0a81a47939af047338..58c321b0cd8d17c1238b00fbdda78a7dbf671d38 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -758,6 +758,7 @@ static int examine_directory(struct Menu *menu, struct BrowserState *state,
 
     init_state(state, menu);
 
+    struct MailboxList ml = neomutt_mailboxlist_get_all(NeoMutt, MUTT_MAILBOX_ANY);
     while ((de = readdir(dp)))
     {
       if (mutt_str_strcmp(de->d_name, ".") == 0)
@@ -783,14 +784,12 @@ static int examine_directory(struct Menu *menu, struct BrowserState *state,
       else if (!S_ISREG(s.st_mode))
         continue;
 
-      struct MailboxList ml = neomutt_mailboxlist_get_all(NeoMutt, MUTT_MAILBOX_ANY);
       struct MailboxNode *np = NULL;
       STAILQ_FOREACH(np, &ml, entries)
       {
         if (mutt_str_strcmp(mutt_b2s(buf), mutt_b2s(np->mailbox->pathbuf)) != 0)
           break;
       }
-      neomutt_mailboxlist_clear(&ml);
 
       if (np && Context && Context->mailbox &&
           (mutt_str_strcmp(np->mailbox->realpath, Context->mailbox->realpath) == 0))
@@ -800,6 +799,7 @@ static int examine_directory(struct Menu *menu, struct BrowserState *state,
       }
       add_folder(menu, state, de->d_name, NULL, &s, np ? np->mailbox : NULL, NULL);
     }
+    neomutt_mailboxlist_clear(&ml);
     closedir(dp);
   }
   browser_sort(state);