From ee3119cee66ec58896cada0ca5998faff05387bd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 5 Jul 2001 00:04:30 +0000 Subject: make sure we reset the shift state on error for charsets like SJIS (This used to be commit 42648a7aada48220fdfaf6acfe95b9614122f1da) --- source3/lib/iconv.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'source3/lib/iconv.c') diff --git a/source3/lib/iconv.c b/source3/lib/iconv.c index b03a146d4f..a5a7a847b5 100644 --- a/source3/lib/iconv.c +++ b/source3/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 -- cgit