gdi32: Add a helper to free a face object and fix a potential memory leak.

This commit is contained in:
Huw Davies 2012-03-27 11:48:45 +01:00 committed by Alexandre Julliard
parent b5115f77bc
commit 8d50bb6711
1 changed files with 10 additions and 4 deletions

View File

@ -1668,6 +1668,15 @@ static inline void get_fontsig( FT_Face ft_face, FONTSIGNATURE *fs )
}
}
static inline void free_face( Face *face )
{
HeapFree( GetProcessHeap(), 0, face->file );
HeapFree( GetProcessHeap(), 0, face->StyleName );
HeapFree( GetProcessHeap(), 0, face->FullName );
HeapFree( GetProcessHeap(), 0, face->cached_enum_data );
HeapFree( GetProcessHeap(), 0, face );
}
#define ADDFONT_EXTERNAL_FONT 0x01
#define ADDFONT_FORCE_BITMAP 0x02
#define ADDFONT_ADD_TO_CACHE 0x04
@ -1709,10 +1718,7 @@ static void AddFaceToList(FT_Face ft_face, const char *file, void *font_data_ptr
} else {
TRACE("Replacing original with this one\n");
list_remove(&face->entry);
HeapFree(GetProcessHeap(), 0, face->file);
HeapFree(GetProcessHeap(), 0, face->StyleName);
HeapFree(GetProcessHeap(), 0, face->FullName);
HeapFree(GetProcessHeap(), 0, face);
free_face( face );
break;
}
}