[cairo-commit] src/cairo-ft-font.c src/cairo-win32-font.c

Adrian Johnson ajohnson at kemper.freedesktop.org
Fri Jul 22 05:25:22 PDT 2011


 src/cairo-ft-font.c    |    4 +++-
 src/cairo-win32-font.c |    4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

New commits:
commit abf97c8874430e40439aae254b16a79dc3d81c4d
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Fri Jul 22 21:37:01 2011 +0930

    Check glyph_index range in _index_to_glyph_name
    
    A broken font such as the PDF file at
    https://bugzilla.gnome.org/show_bug.cgi?id=638011 can mean there are
    less glyph names in the array than there should be.

diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index 822833a..a603ada 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -2481,7 +2481,9 @@ _cairo_index_to_glyph_name (void	         *abstract_font,
      * we fall back to searching the entire array.
      */
 
-    if (strcmp (glyph_names[glyph_index], buffer) == 0) {
+    if (glyph_index < num_glyph_names &&
+	strcmp (glyph_names[glyph_index], buffer) == 0)
+    {
 	*glyph_array_index = glyph_index;
 
 	return CAIRO_STATUS_SUCCESS;
diff --git a/src/cairo-win32-font.c b/src/cairo-win32-font.c
index 67ec51d..34b7179 100644
--- a/src/cairo-win32-font.c
+++ b/src/cairo-win32-font.c
@@ -1693,8 +1693,10 @@ _cairo_win32_scaled_font_index_to_glyph_name (void	      	*abstract_font,
 	*glyph_array_index = scaled_font->type1_notdef_index;
     else if (glyph_index <= scaled_font->type1_notdef_index)
 	*glyph_array_index = glyph_index - 1;
-    else
+    else if (glyph_index < num_glyph_names)
 	*glyph_array_index = glyph_index;
+    else
+	return CAIRO_INT_STATUS_UNSUPPORTED;
 
     return CAIRO_STATUS_SUCCESS;
 }


More information about the cairo-commit mailing list