diff options
author | Andrew Tridgell <tridge@samba.org> | 2001-07-05 00:04:30 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2001-07-05 00:04:30 +0000 |
commit | ee3119cee66ec58896cada0ca5998faff05387bd (patch) | |
tree | e61794f8b0efa8fc539088d95470de60ef9750e0 /source3/lib | |
parent | 6b97f76be844a333502c1f17c65fb9e909599915 (diff) | |
download | samba-ee3119cee66ec58896cada0ca5998faff05387bd.tar.gz samba-ee3119cee66ec58896cada0ca5998faff05387bd.tar.bz2 samba-ee3119cee66ec58896cada0ca5998faff05387bd.zip |
make sure we reset the shift state on error for charsets like SJIS
(This used to be commit 42648a7aada48220fdfaf6acfe95b9614122f1da)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/iconv.c | 11 |
1 files changed, 10 insertions, 1 deletions
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 |