[MPlayer-dev-eng] [PATCH] fix a memleak on sub_font, it was never freed

Guillaume LECERF foxcore at gmail.com
Wed Dec 26 17:18:54 CET 2007


2007/12/26, Ulion <ulion2002 at gmail.com>:
> Futher review:
> should not add this:
> +static int done_freetype(void) { return 0; }
>
> I thinks there's no need the #if defined || defined, only
> done_freetype() need a #ifdef:
>
> -#ifdef HAVE_FREETYPE
> +#if defined(HAVE_FREETYPE) || defined(HAVE_BITMAP_FONT)
>    current_module="uninit_font";
>    if (vo_font) free_font_desc(vo_font);
>    vo_font = NULL;
> +  if (sub_font) (sub_font);
> +  sub_font = NULL;
>    done_freetype();
>  #endif

Changed.

> And also the double free check, need be fixed here.
>
> And because sometimes vo_font and sub_font pointing to the same
> address, then in the load_font_ft, the free is not safe, right? before
> call the load_font_ft, you must take good care of your vo_font and
> sub_font, so you'd better free them before call the load_font_ft or
> clear one  of them if they have same target address to prevent from
> double free. Or any other better plan?

I fixed it differently, as I will need two different instances of
font_dest_t for font and subfont, to deal with the scale factor.
So here is the corresponding patch.

-- 
Guillaume LECERF
GeeXboX developer - www.geexbox.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: font-instances.diff
Type: text/x-diff
Size: 650 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20071226/2f952549/attachment.diff>


More information about the MPlayer-dev-eng mailing list