diff options
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 |