From: Thomas Roessler Date: Thu, 15 Feb 2001 08:09:26 +0000 (+0000) Subject: Fix iconv-hook. It would segfault with x-unknown and other X-Git-Tag: mutt-1-3-16-rel~18 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8f49975c173132293ea86d073e6c20a264d3f17f;p=mutt Fix iconv-hook. It would segfault with x-unknown and other problematic cases. --- diff --git a/charset.c b/charset.c index 7003eaeb..324652c1 100644 --- a/charset.c +++ b/charset.c @@ -305,6 +305,7 @@ iconv_t mutt_iconv_open (const char *tocode, const char *fromcode, int flags) { char tocode1[SHORT_STRING]; char fromcode1[SHORT_STRING]; + char *tocode2, *fromcode2; char *tmp; iconv_t cd; @@ -319,8 +320,10 @@ iconv_t mutt_iconv_open (const char *tocode, const char *fromcode, int flags) if ((cd = iconv_open (tocode1, fromcode1)) != (iconv_t) -1) return cd; - /* else */ - return iconv_open (mutt_iconv_hook (tocode1), mutt_iconv_hook (fromcode1)); + if ((tocode2 = mutt_iconv_hook (tocode1)) && (fromcode2 = mutt_iconv_hook (fromcode1))) + return iconv_open (tocode2, fromcode2); + + return (iconv_t) -1; }