Bug 687429 - Form XObject's /BBox may contain reals in exponential format
Summary: Form XObject's /BBox may contain reals in exponential format
Status: NOTIFIED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Writer (show other bugs)
Version: master
Hardware: PC All
: P2 normal
Assignee: Igor Melichev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-18 12:45 UTC by SaGS
Modified: 2008-12-19 08:31 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments
Sample file (1.56 KB, application/postscript)
2004-04-18 12:49 UTC, SaGS
Details
Proposed patch. (5.24 KB, patch)
2004-04-18 12:50 UTC, SaGS
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description SaGS 2004-04-18 12:45:44 UTC
pdfmark_BP() uses sprintf("%g") to create the value of a Form 
XObject's /BBox. For unexpectedly large values, or values near 0.0 
(coming from rounding errors, for example), "%g" outputs the 
numbers in exponential format, which is not valid in PDFs. 
Adobe Reader signals an error and does not display the PDF file 
obtained from the attached sample.

The proposed patch also introduces a new utlility function 
sprintg(), which is more robust than existing code in pprintg1(). 
The old code may switch to sprintf("%1.1f"); for unexpectedly 
large numbers this produces hundreds of characters, overflowing 
the output buffer (for 1e300 it outputs more than 300 chars). 
sprintg() can also signal an error, by returning NULL.
Comment 1 SaGS 2004-04-18 12:49:33 UTC
Created attachment 625 [details]
Sample file
Comment 2 SaGS 2004-04-18 12:50:54 UTC
Created attachment 626 [details]
Proposed patch.

Changes tested with GS8.13, but diffs are relative to HEAD.

The proposed patch fixes only this particular bug. After applying 
it, the attached PostScript converts to a valid PDF but the 
Form XObjects are still displayed incorrectly. See bug 687430 
"Wrong transformation matrix with Form XObjects".
Comment 3 Igor Melichev 2004-05-25 04:10:17 UTC
Thank you for the patch suggested.
I used your information to make a simpler one 
http://cvs.ghostscript.com/cgi-bin/viewcvs.cgi/gs/src/gdevpdfm.c?r1=1.36&r2=1.37