[MPlayer-dev-eng] [PATCH] Libass BOM fix

Ivan Kalvachev ikalvachev at gmail.com
Sat Oct 27 16:43:31 CEST 2007


2007/10/27, Evgeniy Stepanov <eugeni.stepanov at gmail.com>:
> On Saturday 27 October 2007 18:01:29 Ulion wrote:
> > Hello,
> >
> > A memory leak bug found in sub_recode, my fix is here:
> >
> > Index: libass/ass.c
> > ===================================================================
> > --- libass/ass.c        (revision 24859)
> > +++ libass/ass.c        (working copy)
> > @@ -804,12 +804,14 @@
> >         assert(codepage);
> >
> >         {
> > -               char* cp_tmp = codepage ? strdup(codepage) : 0;
> > +               char* cp_tmp = codepage;
> >  #ifdef HAVE_ENCA
> > +               int free_cp_tmp = 0;
> >                 char enca_lang[3], enca_fallback[100];
> >                 if (sscanf(codepage, "enca:%2s:%99s", enca_lang,
> > enca_fallback) == 2
> >
> >                                 || sscanf(codepage, "ENCA:%2s:%99s",
> >
> > enca_lang, enca_fallback) == 2) {
> >                         cp_tmp = guess_buffer_cp((unsigned char*)data,
> > size, enca_lang, enca_fallback);
> > +                       free_cp_tmp = 1;
> >                 }
> >  #endif
> >                 if ((icdsc = iconv_open (tocp, cp_tmp)) != (iconv_t)(-1)){
> > @@ -817,7 +819,7 @@
> >                 } else
> >
> > mp_msg(MSGT_ASS,MSGL_ERR,MSGTR_LIBASS_ErrorOpeningIconvDescriptor);
> >  #ifdef HAVE_ENCA
> > -               if (cp_tmp) free(cp_tmp);
> > +               if (free_cp_tmp) free(cp_tmp);
> >  #endif
> >         }
>
> Seems ok, you can apply it

I think I have better idea.
langauges are const chars, so they don't have to be strdup-ed over and
over again.
It also requires similar change in the subtitle.c file.
I'll send the patch in hour (after I finish test compile:)



More information about the MPlayer-dev-eng mailing list