aboutsummaryrefslogtreecommitdiff
path: root/freetype/src/cache/ftccmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'freetype/src/cache/ftccmap.c')
-rw-r--r--freetype/src/cache/ftccmap.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/freetype/src/cache/ftccmap.c b/freetype/src/cache/ftccmap.c
index 6728ad317..bc0e66075 100644
--- a/freetype/src/cache/ftccmap.c
+++ b/freetype/src/cache/ftccmap.c
@@ -4,7 +4,8 @@
/* */
/* FreeType CharMap cache (body) */
/* */
-/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, */
+/* 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -153,7 +154,7 @@
FTC_CMapQuery query = (FTC_CMapQuery)ftcquery;
FT_Error error;
FT_Memory memory = cache->memory;
- FTC_CMapNode node;
+ FTC_CMapNode node = NULL;
FT_UInt nn;
@@ -310,19 +311,11 @@
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
/*
- * Detect a call from a rogue client that thinks it is linking
- * to FreeType 2.1.7. This is possible because the third parameter
- * is then a character code, and we have never seen any font with
- * more than a few charmaps, so if the index is very large...
- *
- * It is also very unlikely that a rogue client is interested
- * in Unicode values 0 to 15.
- *
- * NOTE: The original threshold was 4, but we found a font from the
- * Adobe Acrobat Reader Pack, named `KozMinProVI-Regular.otf',
- * which contains more than 5 charmaps.
+ * If cmap_index is greater than the maximum number of cachable
+ * charmaps, we assume the request is from a legacy rogue client
+ * using old internal header. See include/config/ftoption.h.
*/
- if ( cmap_index >= 16 && !no_cmap_change )
+ if ( cmap_index > FT_MAX_CHARMAP_CACHEABLE && !no_cmap_change )
{
FTC_OldCMapDesc desc = (FTC_OldCMapDesc) face_id;
@@ -384,7 +377,7 @@
/* something rotten can happen with rogue clients */
if ( (FT_UInt)( char_code - FTC_CMAP_NODE( node )->first >=
FTC_CMAP_INDICES_MAX ) )
- return 0;
+ return 0; /* XXX: should return appropriate error */
gindex = FTC_CMAP_NODE( node )->indices[char_code -
FTC_CMAP_NODE( node )->first];
@@ -401,6 +394,12 @@
if ( error )
goto Exit;
+#ifdef FT_MAX_CHARMAP_CACHEABLE
+ /* something rotten can happen with rogue clients */
+ if ( cmap_index > FT_MAX_CHARMAP_CACHEABLE )
+ return 0; /* XXX: should return appropriate error */
+#endif
+
if ( (FT_UInt)cmap_index < (FT_UInt)face->num_charmaps )
{
FT_CharMap old, cmap = NULL;