should, free the return value.
- * Return the charset for a particular content type. Return pointer is
- * only valid until the next call to content_charset().
+ * Return the charset for a particular content type.
*/
char *
content_charset (CT ct) {
*/
char *
content_charset (CT ct) {
- static char *ret_charset = NULL;
-
- if (ret_charset != NULL) {
- free(ret_charset);
- }
+ char *ret_charset = NULL;
ret_charset = get_param(ct->c_ctinfo.ci_first_pm, "charset", '?', 0);
ret_charset = get_param(ct->c_ctinfo.ci_first_pm, "charset", '?', 0);
- return ret_charset ? ret_charset : "US-ASCII";
+ return getcpy (ret_charset ? ret_charset : "US-ASCII");
if ((fd = (*ct->c_ceopenfnx) (ct, &file)) == NOTOK)
return NOTOK;
} else {
if ((fd = (*ct->c_ceopenfnx) (ct, &file)) == NOTOK)
return NOTOK;
} else {
+ char *charset = content_charset (ct);
admonish (NULL, "unable to convert character set%s%s to %s",
ct->c_partno ? " of part " : "",
ct->c_partno ? ct->c_partno : "",
admonish (NULL, "unable to convert character set%s%s to %s",
ct->c_partno ? " of part " : "",
ct->c_partno ? ct->c_partno : "",
+ charset);
+ free (charset);
if ((conv_desc = iconv_open (dest_charset, src_charset)) ==
(iconv_t) -1) {
advise (NULL, "Can't convert %s to %s", src_charset, dest_charset);
if ((conv_desc = iconv_open (dest_charset, src_charset)) ==
(iconv_t) -1) {
advise (NULL, "Can't convert %s to %s", src_charset, dest_charset);
#endif /* ! HAVE_ICONV */
}
#endif /* ! HAVE_ICONV */
}
} else {
status = NOTOK;
}
} else {
status = NOTOK;
}
#else /* ! HAVE_ICONV */
NMH_UNUSED (ct);
NMH_UNUSED (file);
#else /* ! HAVE_ICONV */
NMH_UNUSED (ct);
NMH_UNUSED (file);