Commit 0729bc9f5223aeefa6d0bf8573a2ba0634cc1ca6

suzuki toshiya 2009-09-10T16:09:55

[Win64] Improve the computation of random seed from stack address.

diff --git a/ChangeLog b/ChangeLog
index 116c2ce..0f63c43 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2009-09-10  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
+
+	[Win64] Improve the computation of random seed from stack address.
+
+	On LLP64 platform, the conversion from pointer to FT_Fixed need
+	to drop higher 32-bit. Explict casts are required. Reported by
+	NightStrike from MinGW-w64 project. See
+	http://lists.gnu.org/archive/html/freetype/2009-09/msg00000.html
+
+	* src/cff/cffgload.c: Convert the pointers to FT_Fixed explicitly.
+
+	* src/psaux/t1decode.c: Ditto.
+
+
 2009-09-03  Werner Lemberg  <wl@gnu.org>
 
 	[raster] Improvements for stand-alone mode.
diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c
index a5b3e84..40fa20b 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -878,9 +878,10 @@
     decoder->read_width = 1;
 
     /* compute random seed from stack address of parameter */
-    seed = (FT_Fixed)(char*)&seed           ^
-           (FT_Fixed)(char*)&decoder        ^
-           (FT_Fixed)(char*)&charstring_base;
+    seed = (FT_Fixed)( ( (FT_PtrDist)(char*)&seed              ^
+                         (FT_PtrDist)(char*)&decoder           ^
+                         (FT_PtrDist)(char*)&charstring_base ) &
+                         FT_ULONG_MAX ) ;
     seed = ( seed ^ ( seed >> 10 ) ^ ( seed >> 20 ) ) & 0xFFFFL;
     if ( seed == 0 )
       seed = 0x7384;
diff --git a/src/psaux/t1decode.c b/src/psaux/t1decode.c
index 733ad5b..40fbaca 100644
--- a/src/psaux/t1decode.c
+++ b/src/psaux/t1decode.c
@@ -376,9 +376,10 @@
 
 
     /* compute random seed from stack address of parameter */
-    seed = (FT_Fixed)(char*)&seed           ^
-           (FT_Fixed)(char*)&decoder        ^
-           (FT_Fixed)(char*)&charstring_base;
+    seed = (FT_Fixed)( ( (FT_PtrDist)(char*)&seed              ^
+                         (FT_PtrDist)(char*)&decoder           ^
+                         (FT_PtrDist)(char*)&charstring_base ) &
+                         FT_ULONG_MAX ) ;
     seed = ( seed ^ ( seed >> 10 ) ^ ( seed >> 20 ) ) & 0xFFFFL;
     if ( seed == 0 )
       seed = 0x7384;