Bug 692174

Summary: Minimal PDF File views correctly in Acrobat, report range check in GhostScript
Product: Ghostscript Reporter: Andrew Wilcock <andrew_wilcock>
Component: PDF InterpreterAssignee: Alex Cherepanov <alex>
Status: RESOLVED FIXED    
Severity: major    
Priority: P4    
Version: 9.02   
Hardware: PC   
OS: Windows 7   
Customer: Word Size: ---
Attachments: PDF File showing the range check error

Description Andrew Wilcock 2011-04-28 18:37:57 UTC
Created attachment 7480 [details]
PDF File showing the range check error

Simple PDF File [attached] containing a single filled circle fails to load in Ghostscript 9.02. Works fine in Acrobat 9.4.3.


Command and Output is:
$ "C:/Program Files/gs/gs9.02/bin/gswin64c.exe" incorrect_in_gs.pdf

GPL Ghostscript 9.02 (2011-03-30)
Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 1.
Page 1
Error: /rangecheck in --makepattern--
Operand stack:
   --dict:8/17(L)--   --dict:14/23(L)--   --dict:14/23(L)--   --nostringval--   false   --dict:14/15(L)--   --nostringval--
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1910   1   3   %oparray_pop   1909   1   3   %oparray_pop   1893   1   3   %oparray_pop   --nostringval--   --nostringval--   2   1   1   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   %array_continue   --nostringval--   false   1   %stopped_push   --nostringval--   %loop_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   1859   4   10   %oparray_pop   --nostringval--
Dictionary stack:
   --dict:1157/1684(ro)(G)--   --dict:1/20(G)--   --dict:82/200(L)--   --dict:82/200(L)--   --dict:108/127(ro)(G)--   --dict:295/300(ro)(G)--   --dict:23/30(L)--   --dict:6/8(L)--   --dict:21/40(L)--   --dict:5/5(L)--
Current allocation mode is local
Last OS error: No such file or directory
GPL Ghostscript 9.02: Unrecoverable error, exit code 1
Comment 1 Alex Cherepanov 2011-04-30 13:28:38 UTC
Normalize pattern /BBox in PDF interpreter before passing it to PS
to avoid a /rangecheck error.

--- a/gs/Resource/Init/pdf_draw.ps
+++ b/gs/Resource/Init/pdf_draw.ps
@@ -963,6 +963,7 @@ currentdict /ICCBased-resolve undef
     2 index /Resources knownoget { oforce } { 0 dict } ifelse
     /.pdfpaintproc cvx
   ] cvx put
+  dup /BBox 2 copy knownoget { normrect put } { pop pop } ifelse
   dup /.pattern_uses_transparency  1 index patternusestransparency put
   PDFDEBUG { pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%Pattern: ) print dup === flush } if } if
 } bdef

The patch has been committed as a rev. 
c98ade33d2b8fbc0ca6579c6d9e0ceb425374b0c