Bug 46964

Summary: [patch] possible regression, poppler 4Mar12 pdftops makes postscript arrays 65535 times larger than 0.18.4
Product: poppler Reporter: William Bader <williambader>
Component: utilsAssignee: poppler-bugs <poppler-bugs>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: williambader
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: patch against poppler cloned from git on 4Mar12

Description William Bader 2012-03-04 11:44:07 UTC
Created attachment 58010 [details] [review]
patch against poppler cloned from git on 4Mar12

The size of arrays with image data changed from using "outerSize" to "size".
For example, when I compare "pdftops output-pdftopsbug.pdf" (my test file for slanted text), I get sequences like the one below, where the "1 array dup" is from 0.18.4 and the "<large number> array dup" is from a git clone from 4Mar12.
Since the 0.18.4 version works, I think that the larger allocation is unnecessary and might cause problems by wasting memory in the postscript interpreter.

William

Comparison of 0.18.4 and git 4Mar12.

-1 array dup /ImData_79_0 exch def
+1031 array dup /ImData_79_0 exch def
 1031 array 1 index 0 2 index put
 dup 0 ...
 dup 1 ...
 dup 1029 ...
 1030 <> put
 pop
-1 array dup /ImData_85_0 exch def
+1053 array dup /ImData_85_0 exch def
 1053 array 1 index 0 2 index put
 dup 0 ...
 dup 1 ...
@@ -24587,7 +24595,7 @@
 dup 1051 ...
 1052 <> put
 pop
-1 array dup /ImData_91_0 exch def
+1062 array dup /ImData_91_0 exch def
 1062 array 1 index 0 2 index put

PSOutput.cc switched from using "outerSize" in 0.18.4 to "size" in git 4Mar12.

--- /u3/gnu/poppler-0.18.4-wb/poppler/PSOutputDev.cc    2012-02-23 04:45:01.768411089 +0100
+++ /u3/gnu/poppler-git-4mar12-wb/poppler/PSOutputDev.cc        2012-03-04 19:50:18.430407830 +0100
@@ -2780,22 +2851,22 @@
     }
   } while (c != (useASCIIHex ? '>' : '~') && c != EOF);
   // add one entry for the final line of data; add another entry
   // because the RunLengthDecode filter may read past the end
   ++size;
   if (useRLE) {
     ++size;
   }
   outerSize = size/65535 + 1;

-  writePSFmt("{0:d} array dup /ImData_{1:d}_{2:d} exch def\n",
-            outerSize, id.num, id.gen);
+  writePSFmt("{0:d} array dup /{1:s}Data_{2:d}_{3:d} exch def\n",
+            size, mask ? "Mask" : "Im", id.num, id.gen);
   str->close();

   // write the data into the array
   str->reset();
   for (outer = 0;outer < outerSize;outer++) {
     int innerSize = size > 65535 ? 65535 : size;

     // put the inner array into the outer array
     writePSFmt("{0:d} array 1 index {1:d} 2 index put\n",
               innerSize, outer);
Comment 1 Albert Astals Cid 2012-03-05 14:06:54 UTC
Commited.
Comment 2 William Bader 2012-03-05 17:47:07 UTC
Thanks!

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.