vcl/source/gdi/pngread.cxx | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
New commits: commit 9d2fa0bfdc93fa9bfed7dea89d603b1611d7a6e0 Author: Caolán McNamara <caol...@redhat.com> Date: Wed Jun 22 16:40:03 2016 +0100 crashtesting: fix tdf95481-1.odg reexport to odg failure revealed since commit 81e3ca4f60e6ac0823c1233841c22a759cfe937f Author: Tor Lillqvist <t...@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 diff --git a/vcl/source/gdi/pngread.cxx b/vcl/source/gdi/pngread.cxx index 57dc337..9e4fcb5 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
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits