Kaydet (Commit) 9d2fa0bf authored tarafından Caolán McNamara's avatar Caolán McNamara

crashtesting: fix tdf95481-1.odg reexport to odg failure

revealed since

commit 81e3ca4f
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
üst 56a4c9b9
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment