Commit 7aeee3c50f2656b65f7dc207aa2020bb1398da98

Werner Lemberg 2017-03-18T17:30:42

Introduce FT_UINT_TO_POINTER macro (#50560). We have to make a separate case for Windows 64's LLP64 data model. * builds/unix/ftconfig.in, builds/vms/ftconfig.h, include/freetype/config/ftconfig.h (FT_UINT_TO_POINTER): New macro. * src/truetype/ttgload.c (load_truetype_glyph): Use it.

diff --git a/ChangeLog b/ChangeLog
index ea14f23..6a63518 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2017-03-18  Werner Lemberg  <wl@gnu.org>
 
+	Introduce FT_UINT_TO_POINTER macro (#50560).
+
+	We have to make a separate case for Windows 64's LLP64 data model.
+
+	* builds/unix/ftconfig.in, builds/vms/ftconfig.h,
+	include/freetype/config/ftconfig.h (FT_UINT_TO_POINTER): New macro.
+
+	* src/truetype/ttgload.c (load_truetype_glyph): Use it.
+
+2017-03-18  Werner Lemberg  <wl@gnu.org>
+
 	* src/truetype/ttinterp.c (TT_RunIns): Adjust loop counter (#50573).
 
 	The problematic font that exceeds the old limit is Lato-Regular,
diff --git a/builds/unix/ftconfig.in b/builds/unix/ftconfig.in
index 0bc93f1..b0ef313 100644
--- a/builds/unix/ftconfig.in
+++ b/builds/unix/ftconfig.in
@@ -365,6 +365,15 @@ FT_BEGIN_HEADER
 #endif
 
 
+#ifdef _WIN64
+  /* only 64bit Windows uses the LLP64 data model, i.e., */
+  /* 32bit integers, 64bit pointers                      */
+#define FT_UINT_TO_POINTER( x ) (void*)(FT_UInt64)(x)
+#else
+#define FT_UINT_TO_POINTER( x ) (void*)(unsigned long)(x)
+#endif
+
+
   /*************************************************************************/
   /*                                                                       */
   /* miscellaneous                                                         */
diff --git a/builds/vms/ftconfig.h b/builds/vms/ftconfig.h
index c959ff1..8fbb0f4 100644
--- a/builds/vms/ftconfig.h
+++ b/builds/vms/ftconfig.h
@@ -306,6 +306,15 @@ FT_BEGIN_HEADER
 #endif
 
 
+#ifdef _WIN64
+  /* only 64bit Windows uses the LLP64 data model, i.e., */
+  /* 32bit integers, 64bit pointers                      */
+#define FT_UINT_TO_POINTER( x ) (void*)(FT_UInt64)(x)
+#else
+#define FT_UINT_TO_POINTER( x ) (void*)(unsigned long)(x)
+#endif
+
+
   /*************************************************************************/
   /*                                                                       */
   /* miscellaneous                                                         */
diff --git a/include/freetype/config/ftconfig.h b/include/freetype/config/ftconfig.h
index 9d7f883..0a1e4db 100644
--- a/include/freetype/config/ftconfig.h
+++ b/include/freetype/config/ftconfig.h
@@ -333,6 +333,15 @@ FT_BEGIN_HEADER
 #endif
 
 
+#ifdef _WIN64
+  /* only 64bit Windows uses the LLP64 data model, i.e., */
+  /* 32bit integers, 64bit pointers                      */
+#define FT_UINT_TO_POINTER( x ) (void*)(FT_UInt64)(x)
+#else
+#define FT_UINT_TO_POINTER( x ) (void*)(unsigned long)(x)
+#endif
+
+
   /*************************************************************************/
   /*                                                                       */
   /* miscellaneous                                                         */
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index eecf7af..cd4634f 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -1711,7 +1711,7 @@
 
       /* check whether we already have a composite glyph with this index */
       if ( FT_List_Find( &loader->composites,
-                         (void*)(unsigned long)glyph_index ) )
+                         FT_UINT_TO_POINTER( glyph_index ) ) )
       {
         FT_TRACE1(( "TT_Load_Composite_Glyph:"
                     " infinite recursion detected\n" ));
@@ -1720,13 +1720,13 @@
       }
 
       else if ( node )
-        node->data = (void*)(unsigned long)glyph_index;
+        node->data = FT_UINT_TO_POINTER( glyph_index );
 
       else
       {
         if ( FT_NEW( node ) )
           goto Exit;
-        node->data = (void*)(unsigned long)glyph_index;
+        node->data = FT_UINT_TO_POINTER( glyph_index );
         FT_List_Add( &loader->composites, node );
       }