Bug 58032 - Crash when doing patterns over a mono1 outputdev
Summary: Crash when doing patterns over a mono1 outputdev
Status: RESOLVED FIXED
Alias: None
Product: poppler
Classification: Unclassified
Component: splash backend (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-08 22:11 UTC by Albert Astals Cid
Modified: 2012-12-09 19:59 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

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.