[sfnt] Fix memory leaks in previous patch.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
diff --git a/ChangeLog b/ChangeLog
index 1ff5af6..c2dea8f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2010-01-29 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
+ Fix memory leaks in previous patch.
+
+ * src/sfnt/sfobjs.c (sfnt_load_face): Don't overwrite the strings
+ allocated for face->root.family_name and style_name.
+
+2010-01-29 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
+
New parameters for FT_Open_Face() to ignore preferred family names.
Preferred family names should be used for legacy systems that
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index f83e1ba..b74b1a9 100644
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -737,29 +737,33 @@
/* Foundation (WPF). This flag has been introduced in version */
/* 1.5 of the OpenType specification (May 2008). */
+ face->root.family_name = NULL;
+ face->root.style_name = NULL;
if ( face->os2.version != 0xFFFFU && face->os2.fsSelection & 256 )
{
- GET_NAME( FONT_FAMILY, &face->root.family_name );
- if ( !face->root.family_name || !ignore_preferred_family )
+ if ( !ignore_preferred_family )
GET_NAME( PREFERRED_FAMILY, &face->root.family_name );
+ if ( !face->root.family_name )
+ GET_NAME( FONT_FAMILY, &face->root.family_name );
- GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
- if ( !face->root.style_name || !ignore_preferred_subfamily )
+ if ( !ignore_preferred_subfamily )
GET_NAME( PREFERRED_SUBFAMILY, &face->root.style_name );
+ if ( !face->root.style_name )
+ GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
}
else
{
GET_NAME( WWS_FAMILY, &face->root.family_name );
+ if ( !face->root.family_name && !ignore_preferred_family )
+ GET_NAME( PREFERRED_FAMILY, &face->root.family_name );
if ( !face->root.family_name )
GET_NAME( FONT_FAMILY, &face->root.family_name );
- if ( !face->root.family_name || !ignore_preferred_family )
- GET_NAME( PREFERRED_FAMILY, &face->root.family_name );
GET_NAME( WWS_SUBFAMILY, &face->root.style_name );
+ if ( !face->root.style_name && !ignore_preferred_subfamily )
+ GET_NAME( PREFERRED_SUBFAMILY, &face->root.style_name );
if ( !face->root.style_name )
GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
- if ( !face->root.style_name || !ignore_preferred_subfamily )
- GET_NAME( PREFERRED_SUBFAMILY, &face->root.style_name );
}
/* now set up root fields */