Bug 58032

Summary: Crash when doing patterns over a mono1 outputdev
Product: poppler Reporter: Albert Astals Cid <aacid>
Component: splash backendAssignee: poppler-bugs <poppler-bugs>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Albert Astals Cid 2012-12-08 22:11:45 UTC
When running
pdftoppm -r72 -mono over https://bugs.kde.org/attachment.cgi?id=11961 it crashes when creating the SplashBitmap.

The obvious solution is changing 

  if (rowSize > 0) {
    rowSize += rowPad - 1;
    rowSize -= rowSize % rowPad;
  }

to

  if (rowSize > 0 && rowPad > 0) {
    rowSize += rowPad - 1;
    rowSize -= rowSize % rowPad;
  }

But i'm creating this bug to get Thomas' opinion on it
Comment 1 Albert Astals Cid 2012-12-08 22:13:21 UTC
So, Thomas, what's your opinion?
Comment 2 Thomas Freitag 2012-12-09 09:58:13 UTC
First of all, a rowPad of 0 doesn't make any sense (rowPad of 1 means byte boundary, what should then be a rowPad = 0), so the error is in (my) SplashOutputDev::tilingPatternFill, it should be

bitmap = new SplashBitmap(surface_width, surface_height, 1,
                            (paintType == 1) ? colorMode : splashModeMono8, gTrue);

instead of

  bitmap = new SplashBitmap(surface_width, surface_height, colorMode != splashModeMono1,
                            (paintType == 1) ? colorMode : splashModeMono8, gTrue);

(who ever insert this curious code :-) )

But because rowPad is a parameter of SplashoutputDev, and anybody can make the same mistake than I, it's probably a good idea to avoid dividing by 0. But I would then change it to
  
  if (rowSize > 0 && rowPad > 1) {
    rowSize += rowPad - 1;
    rowSize -= rowSize % rowPad;
  }

 (why calling statements which change nothing in case of rowPad = 1)
Comment 3 Albert Astals Cid 2012-12-09 19:59:00 UTC
In the quest for the smallest change i've just changed the first (i.e. colorMode != splashModeMono1 -> 1) in the "new SplashBitmap"

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.