summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-06-22 16:40:03 +0100
committerCaolán McNamara <caolanm@redhat.com>2016-06-22 17:06:33 +0100
commit9d2fa0bfdc93fa9bfed7dea89d603b1611d7a6e0 (patch)
tree353dd8f9569ea1dd68cc68d105c1f5ca29520685 /vcl
parent56a4c9b9ce28a87f18ea82675d215328905c2f12 (diff)
crashtesting: fix tdf95481-1.odg reexport to odg failure
revealed since commit 81e3ca4f60e6ac0823c1233841c22a759cfe937f Author: Tor Lillqvist <tml@collabora.com> Date: Tue Jun 21 10:34:21 2016 +0300 Use real assert() instead of DBG_ASSERT() sanitize invalid palette entry indexes at the outer perimeter on initial load to try and avoid having to do it in all sort of places in the interior. png spec says that the palette has to appear before the first IDAT so we should always know the palette size here Change-Id: I6e04223adce1c88d037f9cf34862e6f54e381bb0
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/gdi/pngread.cxx22
1 files changed, 21 insertions, 1 deletions
diff --git a/vcl/source/gdi/pngread.cxx b/vcl/source/gdi/pngread.cxx
index 57dc337ad296..9e4fcb58adc4 100644
--- a/vcl/source/gdi/pngread.cxx
+++ b/vcl/source/gdi/pngread.cxx
@@ -1122,6 +1122,24 @@ void PNGReaderImpl::ImplApplyFilter()
memcpy( mpScanPrior, mpInflateInBuf, mnScansize );
}
+namespace
+{
+ void SanitizePaletteIndexes(sal_uInt8* pEntries, int nLen, BitmapWriteAccess* pAcc)
+ {
+ sal_uInt16 nPaletteEntryCount = pAcc->GetPaletteEntryCount();
+ for (int nX = 0; nX < nLen; ++nX)
+ {
+ if (pEntries[nX] >= nPaletteEntryCount)
+ {
+ SAL_WARN("vcl.gdi", "invalid colormap index: "
+ << static_cast<unsigned int>(pEntries[nX]) << ", colormap len is: "
+ << nPaletteEntryCount);
+ pEntries[nX] = pEntries[nX] % nPaletteEntryCount;
+ }
+ }
+ }
+}
+
// ImplDrawScanlines draws the complete Scanline (nY) into the target bitmap
// In interlace mode the parameter nXStart and nXAdd append to the currently used pass
@@ -1137,7 +1155,7 @@ void PNGReaderImpl::ImplDrawScanline( sal_uInt32 nXStart, sal_uInt32 nXAdd )
// => TODO; also do this for nX here instead of in the ImplSet*Pixel() methods
const sal_uInt32 nY = mnYpos >> mnPreviewShift;
- const sal_uInt8* pTmp = mpInflateInBuf + 1;
+ sal_uInt8* pTmp = mpInflateInBuf + 1;
if ( mpAcc->HasPalette() ) // alphachannel is not allowed by pictures including palette entries
{
switch ( mpAcc->GetBitCount() )
@@ -1304,6 +1322,8 @@ void PNGReaderImpl::ImplDrawScanline( sal_uInt32 nXStart, sal_uInt32 nXAdd )
if( nXAdd == 1 && mnPreviewShift == 0 ) // copy raw line data if possible
{
int nLineBytes = maOrigSize.Width();
+ if (mbPalette)
+ SanitizePaletteIndexes(pTmp, nLineBytes, mpAcc);
mpAcc->CopyScanline( nY, pTmp, ScanlineFormat::N8BitPal, nLineBytes );
}
else