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

lpd at ghostscript.com lpd at ghostscript.com
Sun Oct 22 11:58:27 PDT 2006


Author: lpd
Date: 2006-10-22 11:58:27 -0700 (Sun, 22 Oct 2006)
New Revision: 7117

Modified:
   trunk/gs/src/gstext.c
   trunk/gs/src/gstext.h
   trunk/gs/src/gxchar.c
Log:
Fixes bug: xshow/yshow/xyshow checked the length of the widths array
incorrectly, and the outcome of the check was ignored.  Partially fixes a
discrepancy in PS3 CET 13-27/28/29.


Modified: trunk/gs/src/gstext.c
===================================================================
--- trunk/gs/src/gstext.c	2006-10-22 17:58:51 UTC (rev 7116)
+++ trunk/gs/src/gstext.c	2006-10-22 18:58:27 UTC (rev 7117)
@@ -534,17 +534,19 @@
     const float *x_widths = text->x_widths;
     const float *y_widths = text->y_widths;
 
-    if (index > text->size)
-	return_error(gs_error_rangecheck);
     if (x_widths == y_widths) {
 	if (x_widths) {
 	    index *= 2;
+	    if (index + 1 >= text->widths_size)
+		return_error(gs_error_rangecheck);
 	    pwidth->x = x_widths[index];
 	    pwidth->y = x_widths[index + 1];
 	}
 	else
 	    pwidth->x = pwidth->y = 0;
     } else {
+	if (index >= text->widths_size)
+	    return_error(gs_error_rangecheck);
 	pwidth->x = (x_widths ? x_widths[index] : 0.0);
 	pwidth->y = (y_widths ? y_widths[index] : 0.0);
     }

Modified: trunk/gs/src/gstext.h
===================================================================
--- trunk/gs/src/gstext.h	2006-10-22 17:58:51 UTC (rev 7116)
+++ trunk/gs/src/gstext.h	2006-10-22 18:58:27 UTC (rev 7117)
@@ -111,11 +111,14 @@
 	gs_char s_char;		/* ADD_TO_SPACE_WIDTH & !FROM_GLYPHS */
 	gs_glyph s_glyph;	/* ADD_TO_SPACE_WIDTH & FROM_GLYPHS */
     } space;
-    /* If x_widths == y_widths, widths are taken in pairs. */
-    /* Either one may be NULL, meaning widths = 0. */
+    /*
+     * If x_widths == y_widths, widths are taken in pairs; note that in this
+     * case, widths_size is the number of widths, not the number of pairs.
+     * Either one may be NULL, meaning widths = 0.
+     */
     const float *x_widths;	/* REPLACE_WIDTHS */
     const float *y_widths;	/* REPLACE_WIDTHS */
-    uint widths_size;		/****** PROBABLY NOT NEEDED ******/
+    uint widths_size;		/* REPLACE_WIDTHS */
 } gs_text_params_t;
 
 #define st_gs_text_params_max_ptrs 3

Modified: trunk/gs/src/gxchar.c
===================================================================
--- trunk/gs/src/gxchar.c	2006-10-22 17:58:51 UTC (rev 7116)
+++ trunk/gs/src/gxchar.c	2006-10-22 18:58:27 UTC (rev 7117)
@@ -871,9 +871,12 @@
     gs_state *pgs = penum->pgs;
 
     if (SHOW_IS(penum, TEXT_REPLACE_WIDTHS)) {
+	int code;
 	gs_point dpt;
 
-	gs_text_replaced_width(&penum->text, penum->xy_index - 1, &dpt);
+	code = gs_text_replaced_width(&penum->text, penum->xy_index - 1, &dpt);
+	if (code < 0)
+	    return code;
 	gs_distance_transform2fixed(&pgs->ctm, dpt.x, dpt.y, &penum->wxy);
     } else {
 	double dx = 0, dy = 0;



More information about the gs-cvs mailing list