freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ft-devel] Segfault with otf and face_index == -1


From: Ville Syrjälä
Subject: Re: [ft-devel] Segfault with otf and face_index == -1
Date: Tue, 18 Oct 2005 01:44:43 +0300
User-agent: Mutt/1.4.2i

On Tue, Oct 18, 2005 at 12:36:57AM +0200, David Turner wrote:
> Hi Again,
> 
> no, this is on purpose. If you call FT_New_Face with face_index < 0, it
> should return an empty FT_Face object to indicate that the format is 
> supported
> (otherwise, an error is returned).
> 
> Moreover, the face->num_faces field can be used to determine the number
> of faces within the font file.
> 
> After that, the caller must destroy the FT_Face normally with FT_Done_Face

Ok. You should update the API docs to refelct that. Currently they state 
that with face_index < 0 no face handle is returned. Also the current code 
allows you to pass face_index < 0 and aface == NULL. If that is still 
legal then the following patch is needed to avoid leaks ...I think :)

--- ftobjs.c.orig       2005-10-18 01:20:51.000000000 +0300
+++ ftobjs.c    2005-10-18 01:43:52.000000000 +0300
@@ -1753,6 +1753,9 @@

     if ( aface )
       *aface = face;
+    else
+      FT_Done_Face( face );
+
     goto Exit;

   Fail:



> 
> Regards,
> 
> - David Turner
> - The FreeType Project  (www.freetype.org)
> 
> 
> Ville Syrjälä a écrit :
> 
> >On Tue, Oct 18, 2005 at 12:58:41AM +0300, Ville Syrjälä wrote:
> > 
> >
> >>On Mon, Oct 17, 2005 at 11:18:35PM +0200, David Turner wrote:
> >>   
> >>
> >>>Hello,
> >>>
> >>>thanks, I've commited a fix, which is to never call FT_New_GlyphSlot and 
> >>>FT_New_Size
> >>>within FT_Open_Face when face_index is < 0.
> >>>
> >>>Hope this helps,
> >>>     
> >>>
> >>It works. Thanks.
> >>   
> >>
> >
> >It looks like the current code will leak memory though. AFAICS it needs 
> >something like this:
> >
> >--- ftobjs.c.orig       2005-10-18 01:20:51.000000000 +0300
> >+++ ftobjs.c    2005-10-18 01:20:38.000000000 +0300
> >@@ -1751,8 +1751,11 @@
> >      internal->transform_delta.y = 0;
> >    }
> >
> >-    if ( aface )
> >+    if ( face_index >= 0 )
> >      *aface = face;
> >+    else
> >+      FT_Done_Face( face );
> >+
> >    goto Exit;
> >
> >  Fail:
> >
> > 
> >
> 

-- 
Ville Syrjälä
address@hidden
http://www.sci.fi/~syrjala/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]