From: iive Date: Sun, 28 Oct 2007 14:26:05 +0000 (+0000) Subject: Our enca code uses strdup() on the input encoding name, as we don't modify it we... X-Git-Tag: 0.9.7~241 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ee96f478b7e058556bee463a39794fdb716d4f7c;p=libass Our enca code uses strdup() on the input encoding name, as we don't modify it we can use the original constant string. Uses less memory, code is simpler and faster. Fixes memory leak (noticed by ulion). git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@24879 b3059339-0415-0410-9bf9-f77b7e298cf2 --- diff --git a/libass/ass.c b/libass/ass.c index e18a540..de0dff8 100644 --- a/libass/ass.c +++ b/libass/ass.c @@ -804,7 +804,7 @@ static char* sub_recode(char* data, size_t size, char* codepage) assert(codepage); { - char* cp_tmp = codepage ? strdup(codepage) : 0; + const char* cp_tmp = codepage; #ifdef HAVE_ENCA char enca_lang[3], enca_fallback[100]; if (sscanf(codepage, "enca:%2s:%99s", enca_lang, enca_fallback) == 2 @@ -816,9 +816,6 @@ static char* sub_recode(char* data, size_t size, char* codepage) mp_msg(MSGT_ASS,MSGL_V,"LIBSUB: opened iconv descriptor.\n"); } else mp_msg(MSGT_ASS,MSGL_ERR,MSGTR_LIBASS_ErrorOpeningIconvDescriptor); -#ifdef HAVE_ENCA - if (cp_tmp) free(cp_tmp); -#endif } {