bugThe FreeType Project - Bugs: bug #27494, Memory leak in function...

 
 

bug #27494: Memory leak in function FT_Init_FreeType, file ftinit.c

Submitted by:  None
Submitted on:  Tue 22 Sep 2009 03:22:45 AM UTC  
 
Severity: 3 - NormalItem Group: Incorrect behaviour
Status: InvalidPrivacy: Public
Assigned to: Werner LEMBERG <wl>Open/Closed: Closed
Planned Release: None

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Tue 22 Sep 2009 05:19:08 AM UTC, comment #1:

Thanks for the report. This has been fixed more than two years ago (in FreeType version 2.3.2).

Werner LEMBERG <wl>
Project AdministratorIn charge of this item.
Tue 22 Sep 2009 03:22:45 AM UTC, original submission:

Here is the leaking source code, with comments removed. The leak happens when the call FT_New_Memory() succeeds but FT_New_Library() fails because of out-of-memory error.

FT_EXPORT_DEF( FT_Error )
FT_Init_FreeType( FT_Library *alibrary )
{
FT_Error error;
FT_Memory memory;

memory = FT_New_Memory();
if ( !memory )
{
FT_ERROR(( "FT_Init_FreeType: cannot find memory manager\n" ));
return FT_Err_Unimplemented_Feature;
}

error = FT_New_Library( memory, alibrary );
if ( !error )
{
(*alibrary)->version_major = FREETYPE_MAJOR;
(*alibrary)->version_minor = FREETYPE_MINOR;
(*alibrary)->version_patch = FREETYPE_PATCH;

FT_Add_Default_Modules( *alibrary );
}

return error;
}

In FT_New_Library(), a call is made to FT_NEW:
/* first of all, allocate the library object */
if ( FT_NEW( library ) )
return error;
If this call fails, FT_New_Library() returns error code 0x40 to FT_Init_FreeType(). FT_Init_FreeType() returns without freeing the memory allocated to local variable 'memory', on getting the non-zero error code.

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

 

Carbon-Copy List
  • -unavailable- added by wl (Posted a comment)
  •  

    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 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 22 Sep 2009 05:19:08 AM UTCwlOpen/ClosedOpen=>Closed
      StatusNone=>Invalid
      Assigned toNone=>wl

    Back to the top


    Powered by Savane 3.1-cleanup1