From: Ken Hornstein Date: Fri, 23 Mar 2012 03:34:08 +0000 (-0400) Subject: If the number of messages in a folder is zero, then don't try to X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=c915e11a95bdfb6157eecc81c5df82de65c86796;hp=f423b06bf5ab4a966b17857f027a46e74447f438;p=mmh If the number of messages in a folder is zero, then don't try to clear out the sequence list; this can cause you to run off the beginning of the malloc'd buffer. This can happen when you use "comp" with a draft folder, the draft folder is empty, and you have a previous sequence set in your .mh_profile. As far as I can tell this has been a problem for nearly forever, but I only ran into it recently when adding the readline support. Go figure. --- diff --git a/sbr/seq_add.c b/sbr/seq_add.c index 0bdcfdf..d5109b0 100644 --- a/sbr/seq_add.c +++ b/sbr/seq_add.c @@ -67,7 +67,7 @@ seq_addsel (struct msgs *mp, char *cp, int public, int zero) * If sequence is new, or zero flag is set, then first * clear the bit for this sequence from all messages. */ - if (new_seq || zero) { + if ((new_seq || zero) && mp->nummsg > 0) { for (msgnum = mp->lowmsg; msgnum <= mp->hghmsg; msgnum++) clear_sequence (mp, i, msgnum); } @@ -159,7 +159,7 @@ seq_addmsg (struct msgs *mp, char *cp, int msgnum, int public, int zero) * If sequence is new, or zero flag is set, then first * clear the bit for this sequence from all messages. */ - if (new_seq || zero) { + if ((new_seq || zero) && mp->nummsg > 0) { for (j = mp->lowmsg; j <= mp->hghmsg; j++) clear_sequence (mp, i, j); }