ass_utils: pick first enca match.
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>
Sat, 20 Feb 2016 12:10:37 +0000 (12:10 +0000)
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>
Sat, 20 Feb 2016 12:10:37 +0000 (12:10 +0000)
This is consistent with non-ass enca
handling and avoids a possible memleak.

git-svn-id: svn://git.mplayerhq.hu/mplayer/trunk@37763 b3059339-0415-0410-9bf9-f77b7e298cf2

libass/ass_utils.c

index df7c447..7b54664 100644 (file)
@@ -250,11 +250,12 @@ void *ass_guess_buffer_cp(ASS_Library *library, unsigned char *buffer,
         analyser = enca_analyser_alloc(languages[i]);
         encoding = enca_analyse_const(analyser, buffer, buflen);
         tmp = enca_charset_name(encoding.charset, ENCA_NAME_STYLE_ICONV);
+        enca_analyser_free(analyser);
         if (tmp && encoding.charset != ENCA_CS_UNKNOWN) {
             detected_sub_cp = strdup(tmp);
             ass_msg(library, MSGL_INFO, "ENCA detected charset: %s", tmp);
+            break;
         }
-        enca_analyser_free(analyser);
     }
 
     free(languages);