summaryrefslogtreecommitdiff
path: root/src/base
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2010-02-26 23:48:53 +0100
committerWerner Lemberg <wl@gnu.org>2010-02-26 23:48:53 +0100
commit2415cbf3655073070dda5329d4d0f05645bd5896 (patch)
treee6e5e97fbf31a5bfee7f4a3edef74fd2e18d1788 /src/base
parent10cf38879521b7f16e7f0bc83183f32858de05a1 (diff)
Improve handling of invalid glyph indices in char->index functions.
* src/base/ftobjs.c (FT_Get_First_Char, FT_Get_Next_Char): Use a loop.
Diffstat (limited to 'src/base')
-rw-r--r--src/base/ftobjs.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 46bcd3bb..54c7fb30 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -3095,7 +3095,7 @@
}
result = cmap->clazz->char_index( cmap, (FT_UInt32)charcode );
}
- return result;
+ return result;
}
@@ -3112,11 +3112,13 @@
if ( face && face->charmap )
{
gindex = FT_Get_Char_Index( face, 0 );
- if ( gindex == 0 )
- result = FT_Get_Next_Char( face, 0, &gindex );
+ if ( gindex == 0 || gindex >= (FT_UInt)face->num_glyphs )
+ do {
+ result = FT_Get_Next_Char( face, 0, &gindex );
+ } while ( gindex >= (FT_UInt)face->num_glyphs );
}
- if ( agindex )
+ if ( agindex )
*agindex = gindex;
return result;
@@ -3140,7 +3142,10 @@
FT_CMap cmap = FT_CMAP( face->charmap );
- gindex = cmap->clazz->char_next( cmap, &code );
+ do {
+ gindex = cmap->clazz->char_next( cmap, &code );
+ } while ( gindex >= (FT_UInt)face->num_glyphs );
+
result = ( gindex == 0 ) ? 0 : code;
}