Fix out-of-bounds error when incorporating email from stdin
[mmh] / sbr / seq_setunseen.c
index e628393..bd57a2c 100644 (file)
@@ -8,6 +8,7 @@
 */
 
 #include <h/mh.h>
+#include <h/utils.h>
 
 /*
 ** We scan through the folder and act upon all messages
@@ -22,19 +23,23 @@ 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 */
-               free(dp);
+               mh_free0(&dp);
                return;
        }
 
@@ -61,5 +66,5 @@ seq_setunseen(struct msgs *mp, int doadd)
                }
        }
 
-       free(dp);
+       mh_free0(&dp);
 }