]> diplodocus.org Git - nmh/blobdiff - uip/mhlsbr.c
Whoops, turns out I originally ran this test with XOAUTH set. Fix the
[nmh] / uip / mhlsbr.c
index 8d8fea17ca6a23beeccdb85bd562eb55fd2a03c2..9a35a816ff15ddf3056d0a39d7a5a794bc529b6f 100644 (file)
@@ -778,7 +778,7 @@ evalvar (struct mcomp *c1)
            return 1;
        }
 
-       args = (struct arglist *) calloc((size_t) 1, sizeof(struct arglist));
+       args = (struct arglist *) mh_xcalloc ((size_t) 1, sizeof(struct arglist));
 
        if (arglist_tail)
            arglist_tail->a_next = args;
@@ -875,14 +875,18 @@ parse (void)
 static void
 process (char *folder, char *fname, int ofilen, int ofilec)
 {
-    char *cp = NULL;
-    FILE *fp = NULL;
+    /* static to prevent "might be clobbered" warning from gcc 4.9.2: */
+    static char *cp;
+    static FILE *fp;
     struct mcomp *c1;
     struct stat st;
     struct arglist *ap;
     /* volatile to prevent "might be clobbered" warning from gcc: */
     char *volatile fname2 = fname ? fname : "(stdin)";
 
+    cp = NULL;
+    fp = NULL;
+
     switch (setjmp (env)) {
        case OK: 
            if (fname) {
@@ -904,6 +908,7 @@ process (char *folder, char *fname, int ofilen, int ofilec)
            if (ontty != PITTY)
                SIGNAL (SIGINT, intrser);
            mhlfile (fp, cp, ofilen, ofilec);  /* FALL THROUGH! */
+            free (cp);
 
            for (ap = arglist_head; ap; ap = ap->a_next) {
                fmt_free(ap->a_fmt, 0);
@@ -913,12 +918,11 @@ process (char *folder, char *fname, int ofilen, int ofilec)
            if (arglist_head)
                fmt_free(NULL, 1);
 
-       default: 
+       default:
            if (ontty != PITTY)
                SIGNAL (SIGINT, SIG_IGN);
-           if (mhl_action == NULL && fp != stdin)
+           if (mhl_action == NULL && fp != stdin && fp != NULL)
                fclose (fp);
-           free (cp);
            if (holder.c_text) {
                free (holder.c_text);
                holder.c_text = NULL;
@@ -1184,7 +1188,7 @@ mcomp_format (struct mcomp *c1, struct mcomp *c2)
 
     (q = &pq)->pq_next = NULL;
     while ((cp = getname (ap))) {
-       if ((p = (struct pqpair *) calloc ((size_t) 1, sizeof(*p))) == NULL)
+       if ((p = (struct pqpair *) mh_xcalloc ((size_t) 1, sizeof(*p))) == NULL)
            adios (NULL, "unable to allocate pqpair memory");
        else {
            if ((mp = getm (cp, NULL, 0, error, sizeof(error))) == NULL) {
@@ -1240,7 +1244,7 @@ add_queue (struct mcomp **head, struct mcomp **tail, char *name, char *text, int
 {
     struct mcomp *c1;
 
-    if ((c1 = (struct mcomp *) calloc ((size_t) 1, sizeof(*c1))) == NULL)
+    if ((c1 = (struct mcomp *) mh_xcalloc ((size_t) 1, sizeof(*c1))) == NULL)
        adios (NULL, "unable to allocate comp memory");
     else {
        c1->c_flags = flags & ~INIT;