X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Fmhlsbr.c;h=45d99b037d1f1e585d34187dfd881ce2c7ac6661;hb=80bf776d0a4587c477bb8a248b9dbe1a31e74575;hp=421098cb39ec761151c605461cd70abfb6ffd41a;hpb=dbdc79c387af1820ee5f4bf669b337becde83357;p=mmh diff --git a/uip/mhlsbr.c b/uip/mhlsbr.c index 421098c..45d99b0 100644 --- a/uip/mhlsbr.c +++ b/uip/mhlsbr.c @@ -895,6 +895,7 @@ process (char *folder, char *fname, int ofilen, int ofilec) FILE *fp = NULL; struct mcomp *c1; struct stat st; + struct arglist *ap; switch (setjmp (env)) { case OK: @@ -919,6 +920,14 @@ process (char *folder, char *fname, int ofilen, int ofilec) SIGNAL (SIGINT, intrser); mhlfile (fp, cp, ofilen, ofilec); /* FALL THROUGH! */ + for (ap = arglist_head; ap; ap = ap->a_next) { + fmt_free(ap->a_fmt, 0); + ap->a_fmt = NULL; + } + + if (arglist_head) + fmt_free(NULL, 1); + default: if (ontty != PITTY) SIGNAL (SIGINT, SIG_IGN); @@ -1009,7 +1018,7 @@ mhlfile (FILE *fp, char *mname, int ofilen, int ofilec) switch (state = m_getfld (state, name, buf, sizeof(buf), fp)) { case FLD: case FLDPLUS: - bucket = fmt_addcomp(name, buf); + bucket = fmt_addcomptext(name, buf); for (ip = ignores; *ip; ip++) if (!mh_strcasecmp (name, *ip)) { while (state == FLDPLUS) { @@ -1159,7 +1168,7 @@ mcomp_format (struct mcomp *c1, struct mcomp *c2) if (!(c1->c_flags & ADDRFMT)) { if (c1->c_c_text) - c1->c_c_text->c_text = getcpy (ap); + c1->c_c_text->c_text = ap; if ((cp = strrchr(ap, '\n'))) /* drop ending newline */ if (!cp[1]) *cp = 0; @@ -1168,7 +1177,7 @@ mcomp_format (struct mcomp *c1, struct mcomp *c2) /* Don't need to append a newline, dctime() already did */ c2->c_text = getcpy (buffer); - free (ap); + /* ap is now owned by the component struct, so do NOT free it here */ return; } @@ -1566,6 +1575,7 @@ mhlsbr (int argc, char **argv, FILE *(*action)()) SIGNAL_HANDLER istat = NULL, pstat = NULL, qstat = NULL; char *cp = NULL; struct mcomp *c1; + struct arglist *a, *a2; switch (setjmp (mhlenv)) { case OK: @@ -1602,6 +1612,15 @@ mhlsbr (int argc, char **argv, FILE *(*action)()) free_queue (&msghd, &msgtl); for (c1 = fmthd; c1; c1 = c1->c_next) c1->c_flags &= ~HDROUTPUT; + + a = arglist_head; + while (a) { + if (a->a_nfs) + free(a->a_nfs); + a2 = a->a_next; + free(a); + a = a2; + } return exitstat; } }