summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-07-05 00:04:30 +0000
committerAndrew Tridgell <tridge@samba.org>2001-07-05 00:04:30 +0000
commit42648a7aada48220fdfaf6acfe95b9614122f1da (patch)
treeb554678e69c419513e3ad478d52674db5288285e
parent04575ff17b9b5fe802e66bb8dd1948317ab35485 (diff)
downloadsamba-42648a7aada48220fdfaf6acfe95b9614122f1da.tar.gz
samba-42648a7aada48220fdfaf6acfe95b9614122f1da.tar.xz
samba-42648a7aada48220fdfaf6acfe95b9614122f1da.zip
make sure we reset the shift state on error for charsets like SJIS
-rw-r--r--source/lib/iconv.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/source/lib/iconv.c b/source/lib/iconv.c
index b03a146d4f4..a5a7a847b5f 100644
--- a/source/lib/iconv.c
+++ b/source/lib/iconv.c
@@ -62,7 +62,16 @@ size_t smb_iconv(smb_iconv_t cd,
#ifdef HAVE_NATIVE_ICONV
if (cd->cd) {
- return iconv(cd->cd, inbuf, inbytesleft, outbuf, outbytesleft);
+ size_t ret;
+ ret = iconv(cd->cd, inbuf, inbytesleft, outbuf, outbytesleft);
+
+ /* if there was an error then reset the internal state,
+ this ensures that we don't have a shift state remaining for
+ character sets like SJIS */
+ if (ret == (size_t)-1) {
+ iconv(cd->cd, NULL, NULL, NULL, NULL);
+ }
+ return ret;
}
#endif