X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/7e3c7e296c778c8f2829cf08d83608f1d9de80d6..9322ba2854211794c27fae9468768b80b767c211:/sbr/encode_rfc2047.c diff --git a/sbr/encode_rfc2047.c b/sbr/encode_rfc2047.c index 581214b7..d1ccd2e9 100644 --- a/sbr/encode_rfc2047.c +++ b/sbr/encode_rfc2047.c @@ -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'; @@ -737,7 +743,7 @@ do_reformat: groupflag = mn->m_ingrp; if (mn->m_gname) { - cp = add(mn->m_gname, NULL); + cp = mh_xstrdup(mn->m_gname); } if (reformat) { @@ -792,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; }