]> diplodocus.org Git - nmh/blobdiff - sbr/encode_rfc2047.c
Replace `if (p) free(p)' with `mh_xfree(p)'.
[nmh] / sbr / encode_rfc2047.c
index 953f6e5c436dc187a4435b202e5e39d37c402cdb..aff04c81235cb6891df69c73fdfd3f6d1f4c0bdc 100644 (file)
@@ -281,16 +281,22 @@ field_encode_quoted(const char *name, char **value, const char *charset,
             * allow for the encoded output.
             */
            if (column + (utf8len(p) * 3) > ENCODELINELIMIT - 2) {
-               newline = 1;
+               newline = 1;
            }
        }
     }
 
+    if (q == NULL) {
+       /* This should never happen, but just in case.  Found by
+          clang static analyzer. */
+       admonish (NULL, "null output encoding for %s", *value);
+       return 1;
+    }
     *q++ = '?';
     *q++ = '=';
 
     if (prefixlen)
-       *q++ = '\n';
+       *q++ = '\n';
 
     *q = '\0';
 
@@ -550,6 +556,7 @@ field_encode_address(const char *name, char **value, int encoding,
     char *tmpbuf = NULL;
     size_t tmpbufsize = 0;
     struct mailname *mn;
+    char errbuf[BUFSIZ];
 
     /*
      * Because these are addresses, we need to handle them individually.
@@ -566,7 +573,8 @@ field_encode_address(const char *name, char **value, int encoding,
     output = add(" ", output);
 
     for (groupflag = 0; (mp = getname(*value)); ) {
-       if ((mn = getm(mp, NULL, 0, AD_HOST, NULL)) == NULL) {
+       if ((mn = getm(mp, NULL, 0, errbuf, sizeof(errbuf))) == NULL) {
+           advise(NULL, "%s: %s", errbuf, mp);
            errflag++;
            continue;
        }
@@ -790,11 +798,8 @@ do_reformat:
     output = NULL;
 
 out:
-
-    if (tmpbuf)
-       free(tmpbuf);
-    if (output)
-       free(output);
+    mh_xfree(tmpbuf);
+    mh_xfree(output);
 
     return errflag > 0;
 }