From 8f49975c173132293ea86d073e6c20a264d3f17f Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Thu, 15 Feb 2001 08:09:26 +0000 Subject: [PATCH] Fix iconv-hook. It would segfault with x-unknown and other problematic cases. --- charset.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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; } -- 2.40.0