Fix out-of-bounds error when incorporating email from stdin
[mmh] / sbr / seq_setunseen.c
index 73bd83d..bd57a2c 100644 (file)
@@ -8,7 +8,7 @@
 */
 
 #include <h/mh.h>
-#include <h/utils.h> /* mh_free0() */
+#include <h/utils.h>
 
 /*
 ** We scan through the folder and act upon all messages
@@ -23,15 +23,19 @@ seq_setunseen(struct msgs *mp, int doadd)
        int n;
        char **ap, *cp, *dp;
 
+       if (mp->lowmsg == 0) {
+               return;
+       }
+
        /*
        ** Get the list of sequences for Unseen-Sequence
        ** and split them.
        */
        if ((cp = context_find(usequence))) {
-               dp = getcpy(cp);
+               dp = mh_xstrdup(cp);
        } else {
                /* not set in profile, thus use the default */
-               dp = getcpy(seq_unseen);
+               dp = mh_xstrdup(seq_unseen);
        }
        if (!(ap = brkstring(dp, " ", "\n")) || !*ap) {
                /* contains no sequence name, i.e. we're finished */