[MPlayer-cvslog] r26923 - trunk/libass/ass.c

eugeni subversion at mplayerhq.hu
Thu May 29 20:35:21 CEST 2008


Author: eugeni
Date: Thu May 29 20:35:21 2008
New Revision: 26923

Log:
Clear iconv conversion state also in libass.


Modified:
   trunk/libass/ass.c

Modified: trunk/libass/ass.c
==============================================================================
--- trunk/libass/ass.c	(original)
+++ trunk/libass/ass.c	Thu May 29 20:35:21 2008
@@ -846,13 +846,19 @@ static char* sub_recode(char* data, size
 		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
 					mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_ErrorRecodingFile);
 					return NULL;
 				}
-			}
+			} else
+				if (clear)
+					break;
 		}
 		outbuf[osize - oleft - 1] = 0;
 	}



More information about the MPlayer-cvslog mailing list