[gs-cvs] rev 8211 - trunk/gs/src

leonardo at ghostscript.com leonardo at ghostscript.com
Tue Aug 28 09:06:13 PDT 2007


Author: leonardo
Date: 2007-08-28 09:06:12 -0700 (Tue, 28 Aug 2007)
New Revision: 8211

Modified:
   trunk/gs/src/gdevpsfx.c
Log:
Fix (pdfwrite) : Uninitialized defaultWidthXwhile while converting a Type 1 font into Type 2.

DETAILS :

Bug 689406 "Valgrind: Uninitialised defaultWidthX in psf_convert_type1_to_type2()".

Thanks to Alex for the problem localization and for the suggested patch.
This change is equivalent to Alex's patch
expect the better documentation. 
See comment in code.

The old code accessed pfont->data.defaultWidthX,
which is never used or initialized elsewhere with a Type 1 font,
because defaultWidthX is a Type 2 feature.

EXPECTED DIFFERENCES :

None.

Actually the probability of the correct result with the old code
is not equal to 1, so some differences with glyph positioning 
may appear in some cases. Alex's local test didn't detect a diference 
with comparefiles.


Modified: trunk/gs/src/gdevpsfx.c
===================================================================
--- trunk/gs/src/gdevpsfx.c	2007-08-28 06:34:08 UTC (rev 8210)
+++ trunk/gs/src/gdevpsfx.c	2007-08-28 16:06:12 UTC (rev 8211)
@@ -640,10 +640,16 @@
 	     */
 	    cis.ostack[0] = cis.ostack[1];
 	sbw:
-	    if (cis.ostack[0] == pfont->data.defaultWidthX)
+	    /* cff_write_Private doesn't write defaultWidthX 
+	       when called with the Type 1 font,
+	       so the reader will assume 
+	       defaultWidthX = defaultWidthX_DEFAULT
+	       Use the latter here.
+	     */
+	    if (cis.ostack[0] == defaultWidthX_DEFAULT)
 		cis.os_count = 0;
 	    else {
-		cis.ostack[0] -= pfont->data.nominalWidthX;
+		cis.ostack[0] -= defaultWidthX_DEFAULT;
 		cis.os_count = 1;
 	    }
 	    if (hstem_hints.count) {



More information about the gs-cvs mailing list