diff options
author | 2008-05-29 18:35:21 +0000 | |
---|---|---|
committer | 2008-05-29 18:35:21 +0000 | |
commit | db616d5222a988e4849e49a240dd97564dd9e478 (patch) | |
tree | bd5ea0daf340fd2b19048f4907d0c01438cb62c7 | |
parent | d3e1f76cac618cd2e3a049126b1ac0c2c0641487 (diff) |
Clear iconv conversion state also in libass.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26923 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r-- | libass/ass.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/libass/ass.c b/libass/ass.c index 4b803db95d..c5323289a7 100644 --- a/libass/ass.c +++ b/libass/ass.c @@ -846,13 +846,19 @@ static char* sub_recode(char* data, size_t size, char* codepage) char* ip; char* op; size_t rc; + int clear = 0; outbuf = malloc(size); ip = data; op = outbuf; - while (ileft) { - rc = iconv(icdsc, &ip, &ileft, &op, &oleft); + while (1) { + if (ileft) + rc = iconv(icdsc, &ip, &ileft, &op, &oleft); + else {// clear the conversion state and leave + clear = 1; + rc = iconv(icdsc, NULL, NULL, &op, &oleft); + } if (rc == (size_t)(-1)) { if (errno == E2BIG) { size_t offset = op - outbuf; @@ -864,7 +870,9 @@ static char* sub_recode(char* data, size_t size, char* codepage) mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_ErrorRecodingFile); return NULL; } - } + } else + if (clear) + break; } outbuf[osize - oleft - 1] = 0; } |