bugThe FreeType Project - Bugs: bug #16590, Two memory leaks in 2.2.1

 
 

bug #16590: Two memory leaks in 2.2.1

Submitted by:  None
Submitted on:  Mon 15 May 2006 05:47:31 PM UTC  
 
Severity: 3 - NormalItem Group: None
Status: FixedPrivacy: Public
Assigned to: suzuki toshiya <mpsuzuki>Open/Closed: Closed
Planned Release: 2.3.0

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Fri 19 May 2006 10:56:43 AM UTC, comment #2:

Sorry for lating, proposed patch is applied.

Just I've checked that proposed patch can work well on
all of MacOS X/ppc, classic MacOS/ppc (by MPW), classic
MacOS/m68k (by MPW).

The condition the leak occurs is following:
FreeType2 tries to open MacOS file, and it looks like
resource-fork-housed fonts. Openning the stream by MacOS API,
and pass it to FreeType's font parser. FreeType's parser
finds something wrong, and give it up to open the stream
as font file. But the opened stream is not deallocated.

Making a broken font to cause such problem is a bit
troublesome, so I've tested by following experiment.

By rewinding my patch on 2005/Aug,

http://cvs.savannah.gnu.org/viewcvs/freetype/freetype2/src/sfnt/ttload.c?r1=1.116&r2=1.117

FreeType gets error in parsing some MacOS fonts like
"Osaka Bold", so, now "Osaka Bold" can be used to cause
the problem (looks like proper font, but error in parsing).

Building FreeType after applying proposed patch and
rewinding the part, and bind it ftoldmac in ft2demos,
and I passed "Osaka Bold" to ftoldmac, and tested if
deallocation works well. All tests for each platforms
are successfully passed.

suzuki toshiya <mpsuzuki>
Project AdministratorIn charge of this item.
Wed 17 May 2006 08:59:19 AM UTC, comment #1:

The first one I've applied to the CVS, thanks.

The second problem I've assigned to Toshiya.

Werner LEMBERG <wl>
Project Administrator
Mon 15 May 2006 05:47:31 PM UTC, original submission:

There are two places I've found where allocated memory isn't freed.

First, in src/cff/cffload.c, the "subfonts" array allocated on line 2198 is never released. Here's my fix:

diff -ur freetype-2.2.1/src/cff/cffload.c freetype/src/cff/cffload.c
--- freetype-2.2.1/src/cff/cffload.c 2006-03-21 10:17:26.00 -0800
+++ freetype/src/cff/cffload.c 2006-05-12 13:49:12.00 -0700
@@ -2298,6 +2301,7 @@
{
for ( idx = 0; idx < font->num_subfonts; idx++ )
cff_subfont_done( memory, font->subfonts[idx] );
+ FT_FREE(font->subfonts[0]);
}

cff_encoding_done( &font->encoding );

Second, in src/base/ftmac.c, the stream created on line 983 is not freed (although it does get closed) if the font can't be successfully opened. Here's my fix, although I think there might be a better one were I to understand FT_Open_Face better:

diff -ur freetype-2.2.1/src/base/ftmac.c freetype/src/base/ftmac.c
--- freetype-2.2.1/src/base/ftmac.c 2006-05-02 13:00:44.00 -0700
+++ freetype/src/base/ftmac.c 2006-05-15 10:08:15.00 -0700
@@ -1010,6 +1010,8 @@
error = FT_Open_Face( library, &args, face_index, aface );
if ( error == FT_Err_Ok )
(*aface)->face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM;
+ else
+ FT_Stream_Free(stream, 0);

return error;
}

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 5 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Fri 19 May 2006 09:27:42 PM UTCwlPlanned ReleaseNone=>2.3.0
Fri 19 May 2006 10:56:43 AM UTCmpsuzukiStatusIn Progress=>Fixed
  Open/ClosedOpen=>Closed
Wed 17 May 2006 08:59:19 AM UTCwlStatusNone=>In Progress
  Assigned toNone=>mpsuzuki

Back to the top


Powered by Savane 3.1-cleanup1