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 | 42648a7aada48220fdfaf6acfe95b9614122f1da (patch) | |
tree | b554678e69c419513e3ad478d52674db5288285e | |
parent | 04575ff17b9b5fe802e66bb8dd1948317ab35485 (diff) | |
download | samba-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.c | 11 |
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 |