From db616d5222a988e4849e49a240dd97564dd9e478 Mon Sep 17 00:00:00 2001 From: eugeni Date: Thu, 29 May 2008 18:35:21 +0000 Subject: [PATCH] Clear iconv conversion state also in libass. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26923 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libass/ass.c | 14 +++++++++++--- 1 file 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; }