From fb1c27ed0cbc16d151d182dd3f2be5eb3189a045 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 20 Sep 2010 22:05:08 -0700 Subject: [PATCH] i18n: Ensure that every recoding starts from the initial shift state. --- src/libpspp/i18n.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libpspp/i18n.c b/src/libpspp/i18n.c index 3735e95d84..06c67d9479 100644 --- a/src/libpspp/i18n.c +++ b/src/libpspp/i18n.c @@ -142,6 +142,10 @@ recode_string_pool (const char *to, const char *from, if ( (iconv_t) -1 == conv ) return xstrdup (text); + /* Put the converter into the initial shift state, in case there was any + state information left over from its last usage. */ + iconv (conv, NULL, 0, NULL, 0); + for ( outbufferlength = 1 ; outbufferlength != 0; outbufferlength <<= 1 ) if ( outbufferlength > length) break; @@ -176,6 +180,7 @@ recode_string_pool (const char *to, const char *from, } /* Fall through */ case E2BIG: + iconv (conv, NULL, 0, NULL, 0); pool_free (pool, outbuf); outbufferlength <<= 1; outbuf = pool_malloc (pool, outbufferlength); -- 2.30.2