--- buffy.c +++ buffy.c 2009-04-21 11:10:21.738987896 +0200 @@ -181,7 +181,6 @@ int mutt_parse_mailboxes (BUFFER *path, { for (tmp = &Incoming; *tmp;) { - FREE (&((*tmp)->path)); tmp1=(*tmp)->next; FREE (tmp); /* __FREE_CHECKED__ */ *tmp=tmp1; @@ -216,7 +215,7 @@ int mutt_parse_mailboxes (BUFFER *path, if (!*tmp) { *tmp = (BUFFY *) safe_calloc (1, sizeof (BUFFY)); - (*tmp)->path = safe_strdup (buf); + strfcpy ((*tmp)->path, buf, sizeof ((*tmp)->path)); (*tmp)->next = NULL; /* it is tempting to set magic right here */ (*tmp)->magic = 0; @@ -554,59 +553,31 @@ int mutt_buffy_notify (void) * mutt_buffy() -- incoming folders completion routine * * given a folder name, this routine gives the next incoming folder with new - * new mail. + * mail. */ void mutt_buffy (char *s, size_t slen) { - int count; BUFFY *tmp = Incoming; + int pass, found = 0; - mutt_expand_path (s, _POSIX_PATH_MAX); - switch (mutt_buffy_check (0)) - { - case 0: - - *s = '\0'; - break; + mutt_expand_path (s, slen); - case 1: - - while (tmp && !tmp->new) - tmp = tmp->next; - if (!tmp) - { - *s = '\0'; - mutt_buffy_check (1); /* buffy was wrong - resync things */ - break; - } - strfcpy (s, tmp->path, slen); - mutt_pretty_mailbox (s, slen); - break; - - default: - - count = 0; - while (count < 3) - { - if (mutt_strcmp (s, tmp->path) == 0) - count++; - else if (count && tmp->new) - break; - tmp = tmp->next; - if (!tmp) - { - tmp = Incoming; - count++; + if (mutt_buffy_check (0)) { + for (pass = 0; pass < 2; pass++) + for (tmp = Incoming; tmp; tmp = tmp->next) { + mutt_expand_path (tmp->path, sizeof (tmp->path)); + if ((found || pass) && tmp->new) { + strfcpy (s, tmp->path, slen); + mutt_pretty_mailbox (s, slen); + return; + } + if (mutt_strcmp (s, tmp->path) == 0) + found = 1; } - } - if (count >= 3) - { - *s = '\0'; - mutt_buffy_check (1); /* buffy was wrong - resync things */ - break; - } - strfcpy (s, tmp->path, slen); - mutt_pretty_mailbox (s, slen); - break; + + mutt_buffy_check (1); /* buffy was wrong - resync things */ } + + /* no folders with new mail */ + *s = '\0'; } --- buffy.h +++ buffy.h 2009-04-21 11:10:21.738987896 +0200 @@ -22,7 +22,7 @@ typedef struct buffy_t { - char *path; + char path[_POSIX_PATH_MAX]; off_t size; struct buffy_t *next; struct buffy_t *prev;