summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsuzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>2012-01-15 02:48:47 +0900
committersuzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>2012-01-15 02:48:47 +0900
commit09f3e41c2523f597ecc7d3afdd0aaa8f9659ad06 (patch)
treeea9e0ea21b11f0a83574b698ad3c1015cf4daa53
parent0614febcec522c608a3d4d62cb5eac544af1a4f6 (diff)
downloadfreetype2-09f3e41c2523f597ecc7d3afdd0aaa8f9659ad06.tar.gz
[base] Fix a dereference of uninitialized variable in PIC mode.
* src/base/ftglyph.c (FT_Glyph_To_Bitmap): `glyph' must be set before derefering to obtain `library'. The initialization of `clazz', `glyph', `library' and NULL pointer check are reordered to minimize PIC conditonals.
-rw-r--r--ChangeLog9
-rw-r--r--src/base/ftglyph.c24
2 files changed, 21 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index bbb205b34..0fe07bd87 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2012-01-14 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
+ [base] Fix a dereference of uninitialized variable in PIC mode.
+
+ * src/base/ftglyph.c (FT_Glyph_To_Bitmap): `glyph' must be
+ set before derefering to obtain `library'. The initialization
+ of `clazz', `glyph', `library' and NULL pointer check are
+ reordered to minimize PIC conditonals.
+
+2012-01-14 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
+
[base] Insert explict cast for GCC 4.6 in PIC mode.
* src/base/ftinit.c (FT_Add_Default_Modules): Under PIC
diff --git a/src/base/ftglyph.c b/src/base/ftglyph.c
index b22050800..3d7cf3626 100644
--- a/src/base/ftglyph.c
+++ b/src/base/ftglyph.c
@@ -512,42 +512,42 @@
FT_Error error = FT_Err_Ok;
FT_Glyph glyph;
FT_BitmapGlyph bitmap = NULL;
-
const FT_Glyph_Class* clazz;
-#ifdef FT_CONFIG_OPTION_PIC
- FT_Library library = FT_GLYPH( glyph )->library;
-#endif
+ /* FT_BITMAP_GLYPH_CLASS_GET derefers `library' in PIC mode */
+ FT_Library library;
/* check argument */
if ( !the_glyph )
goto Bad;
-
- /* we render the glyph into a glyph bitmap using a `dummy' glyph slot */
- /* then calling FT_Render_Glyph_Internal() */
-
glyph = *the_glyph;
if ( !glyph )
goto Bad;
- clazz = glyph->clazz;
+ clazz = glyph->clazz;
+ library = glyph->library;
+ if ( !library || !clazz )
+ goto Bad;
/* when called with a bitmap glyph, do nothing and return successfully */
if ( clazz == FT_BITMAP_GLYPH_CLASS_GET )
goto Exit;
- if ( !clazz || !clazz->glyph_prepare )
+ if ( !clazz->glyph_prepare )
goto Bad;
+ /* we render the glyph into a glyph bitmap using a `dummy' glyph slot */
+ /* then calling FT_Render_Glyph_Internal() */
+
FT_MEM_ZERO( &dummy, sizeof ( dummy ) );
FT_MEM_ZERO( &dummy_internal, sizeof ( dummy_internal ) );
dummy.internal = &dummy_internal;
- dummy.library = glyph->library;
+ dummy.library = library;
dummy.format = clazz->glyph_format;
/* create result bitmap glyph */
- error = ft_new_glyph( glyph->library, FT_BITMAP_GLYPH_CLASS_GET,
+ error = ft_new_glyph( library, FT_BITMAP_GLYPH_CLASS_GET,
(FT_Glyph*)(void*)&bitmap );
if ( error )
goto Exit;