changeset 26891:29e92a7a75b6

Clear iconv conversion state also in libass.
author eugeni
date Thu, 29 May 2008 18:35:21 +0000
parents 80bf10a56b7e
children 3c360ca1c304
files libass/ass.c
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libass/ass.c	Thu May 29 18:35:18 2008 +0000
+++ b/libass/ass.c	Thu May 29 18:35:21 2008 +0000
@@ -846,13 +846,19 @@
 		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 @@
 					mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_ErrorRecodingFile);
 					return NULL;
 				}
-			}
+			} else
+				if (clear)
+					break;
 		}
 		outbuf[osize - oleft - 1] = 0;
 	}