[gs-cvs] rev 7079 - trunk/gs/src
leonardo at ghostscript.com
leonardo at ghostscript.com
Tue Oct 3 11:08:38 PDT 2006
Author: leonardo
Date: 2006-10-03 11:08:37 -0700 (Tue, 03 Oct 2006)
New Revision: 7079
Modified:
trunk/gs/src/gdevpdtc.c
trunk/gs/src/gdevpdte.c
Log:
Fix (pdfwrite) : Pacify Valgrind with not touching an uninitialized data.
DETAILS :
Bug 688873 "pdfwrite :Valgrind reports uninitialized data".
The old code checked penum->text.x_widths, penum->text.y_widths
and shifted them forth and back when they are uninitialized.
It was not harmful because those pointers were not defererenced.
Also space.s_char was checked when unitialized.
In those cases it should not be accessed.
EXPECTED DIFFERENCES :
None.
Modified: trunk/gs/src/gdevpdtc.c
===================================================================
--- trunk/gs/src/gdevpdtc.c 2006-10-03 00:31:14 UTC (rev 7078)
+++ trunk/gs/src/gdevpdtc.c 2006-10-03 18:08:37 UTC (rev 7079)
@@ -106,7 +106,8 @@
buf_index++;
prev_font = new_font;
psmat = &curr.fstack.items[curr.fstack.depth - 1].font->FontMatrix;
- if (pte->text.space.s_char == char_code)
+ if ((pte->text.operation & TEXT_ADD_TO_SPACE_WIDTH) &&
+ pte->text.space.s_char == char_code)
space_char = chr;
continue;
case 2: /* end of string */
@@ -151,7 +152,8 @@
break;
buf[0] = (byte)chr;
buf_index = 1;
- space_char = (pte->text.space.s_char == char_code ? chr : ~0);
+ space_char = ((pte->text.operation & TEXT_ADD_TO_SPACE_WIDTH) &&
+ pte->text.space.s_char == char_code ? chr : ~0);
psmat = &curr.fstack.items[curr.fstack.depth - 1].font->FontMatrix;
prev_font = new_font;
}
@@ -542,7 +544,7 @@
if (break_index > index) {
pdf_font_resource_t *pdfont;
gs_matrix m3;
- int xy_index_step = (pte->text.x_widths != NULL && /* see gs_text_replaced_width */
+ int xy_index_step = (!(pte->text.operation & TEXT_REPLACE_WIDTHS) ? 0 :
pte->text.x_widths == pte->text.y_widths ? 2 : 1);
gs_text_params_t save_text;
@@ -579,17 +581,21 @@
save_text = pte->text;
str.data = scan.text.data.bytes + index;
str.size = break_index - index;
- if (pte->text.x_widths != NULL)
- pte->text.x_widths += xy_index * xy_index_step;
- if (pte->text.y_widths != NULL)
- pte->text.y_widths += xy_index * xy_index_step;
+ if (pte->text.operation & TEXT_REPLACE_WIDTHS) {
+ if (pte->text.x_widths != NULL)
+ pte->text.x_widths += xy_index * xy_index_step;
+ if (pte->text.y_widths != NULL)
+ pte->text.y_widths += xy_index * xy_index_step;
+ }
pte->xy_index = 0;
code = process_text_modify_width((pdf_text_enum_t *)pte, (gs_font *)font,
&text_state, &str, &wxy, NULL, true);
- if (pte->text.x_widths != NULL)
- pte->text.x_widths -= xy_index * xy_index_step;
- if (pte->text.y_widths != NULL)
- pte->text.y_widths -= xy_index * xy_index_step;
+ if (pte->text.operation & TEXT_REPLACE_WIDTHS) {
+ if (pte->text.x_widths != NULL)
+ pte->text.x_widths -= xy_index * xy_index_step;
+ if (pte->text.y_widths != NULL)
+ pte->text.y_widths -= xy_index * xy_index_step;
+ }
pte->text = save_text;
pte->cdevproc_callout = false;
if (code < 0) {
Modified: trunk/gs/src/gdevpdte.c
===================================================================
--- trunk/gs/src/gdevpdte.c 2006-10-03 00:31:14 UTC (rev 7078)
+++ trunk/gs/src/gdevpdte.c 2006-10-03 18:08:37 UTC (rev 7079)
@@ -520,22 +520,25 @@
/* process_text_modify_width destroys text parameters, save them now. */
int index0 = penum->index, xy_index = penum->xy_index;
gs_text_params_t text = penum->text;
- int xy_index_step = (penum->text.x_widths != NULL && /* see gs_text_replaced_width */
+ int xy_index_step = (!(penum->text.operation & TEXT_REPLACE_WIDTHS) ? 0 :
penum->text.x_widths == penum->text.y_widths ? 2 : 1);
- if (penum->text.x_widths != NULL) {
- penum->text.x_widths += xy_index * xy_index_step;
+ if (penum->text.operation & TEXT_REPLACE_WIDTHS) {
+ if (penum->text.x_widths != NULL)
+ penum->text.x_widths += xy_index * xy_index_step;
+ if (penum->text.y_widths != NULL)
+ penum->text.y_widths += xy_index * xy_index_step;
}
- if (penum->text.y_widths != NULL)
- penum->text.y_widths += xy_index * xy_index_step;
penum->xy_index = 0;
code = process_text_modify_width(penum, (gs_font *)font, ppts,
(gs_const_string *)pstr,
&width_pt, gdata, false);
- if (penum->text.x_widths != NULL)
- penum->text.x_widths -= xy_index * xy_index_step;
- if (penum->text.y_widths != NULL)
- penum->text.y_widths -= xy_index * xy_index_step;
+ if (penum->text.operation & TEXT_REPLACE_WIDTHS) {
+ if (penum->text.x_widths != NULL)
+ penum->text.x_widths -= xy_index * xy_index_step;
+ if (penum->text.y_widths != NULL)
+ penum->text.y_widths -= xy_index * xy_index_step;
+ }
penum->xy_index += xy_index;
adjust_first_last_char(pdfont, pstr->data, penum->index);
penum->text = text;
More information about the gs-cvs
mailing list