From c915e11a95bdfb6157eecc81c5df82de65c86796 Mon Sep 17 00:00:00 2001 From: Ken Hornstein Date: Thu, 22 Mar 2012 23:34:08 -0400 Subject: [PATCH] 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. --- sbr/seq_add.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); } -- 1.7.10.4