From: David Levine Date: Sun, 4 May 2014 14:03:33 +0000 (-0500) Subject: In mhshow, copy result of call to norm_charmap() and get_charset() X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/ea855e72d026c72658d43f993fc62cfcf2de2ca3?ds=sidebyside In mhshow, copy result of call to norm_charmap() and get_charset() because they return a static buffer. Thanks to Alexander Zangerl for tracking this down, when using an ISO-8859-1 locale. --- diff --git a/uip/mhshowsbr.c b/uip/mhshowsbr.c index d7da96d8..187f9156 100644 --- a/uip/mhshowsbr.c +++ b/uip/mhshowsbr.c @@ -1030,9 +1030,12 @@ convert_charset (CT ct, char *dest_charset, int *message_mods) { /* norm_charmap() is case sensitive. */ char *src_charset_u = upcase (src_charset); char *dest_charset_u = upcase (dest_charset); - int different_charsets = - strcmp (norm_charmap (src_charset), norm_charmap (dest_charset)); + char *src_charset_n = getcpy (norm_charmap (src_charset)); + char *dest_charset_n = getcpy (norm_charmap (dest_charset)); + int different_charsets = strcmp (src_charset_n, dest_charset_n); + free (dest_charset_n); + free (src_charset_n); free (dest_charset_u); free (src_charset_u); @@ -1198,6 +1201,8 @@ iconv_start: static int convert_content_charset (CT ct, char **file) { + int status = OK; + #ifdef HAVE_ICONV /* Using current locale, see if the content needs to be converted. */ @@ -1207,18 +1212,22 @@ convert_content_charset (CT ct, char **file) { if (! check_charset (charset, strlen (charset))) { int unused = 0; - if (convert_charset (ct, get_charset (), &unused) == 0) { + char *charset = getcpy (get_charset ()); + + if (convert_charset (ct, charset, &unused) == 0) { *file = ct->c_cefile.ce_file; } else { - return NOTOK; + status = NOTOK; } + + free (charset); } #else /* ! HAVE_ICONV */ NMH_UNUSED (ct); NMH_UNUSED (file); #endif /* ! HAVE_ICONV */ - return OK; + return status; } /*