filter/source/graphicfilter/itiff/itiff.cxx | 29 ++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-)
New commits: commit 3bcdd9fc24a9bec2997768c6aa7a78a0c1f329ee Author: Caolán McNamara <caol...@redhat.com> Date: Tue Aug 19 15:14:04 2014 +0100 guard against division by 0 valgrind + bff Change-Id: I5fa40f7a9759c98bb70ee6eb854dd9b376401f89 (cherry picked from commit 1ab0e8717bee9fee6c42015647bccfbf1683b8fc) Reviewed-on: https://gerrit.libreoffice.org/11036 Reviewed-by: David Tardon <dtar...@redhat.com> Tested-by: David Tardon <dtar...@redhat.com> diff --git a/filter/source/graphicfilter/itiff/itiff.cxx b/filter/source/graphicfilter/itiff/itiff.cxx index f708435..4122ab2 100644 --- a/filter/source/graphicfilter/itiff/itiff.cxx +++ b/filter/source/graphicfilter/itiff/itiff.cxx @@ -1324,29 +1324,34 @@ bool TIFFReader::ReadTIFF(SvStream & rTIFF, Graphic & rGraphic ) bByteSwap = true; nStripsPerPlane = ( nImageLength - 1 ) / GetRowsPerStrip() + 1; - nBytesPerRow = ( nImageWidth * nSamplesPerPixel / nPlanes * nBitsPerSample + 7 ) >> 3; + bStatus = nPlanes != 0; - for ( sal_uLong j = 0; j < 4; j++ ) + if (bStatus) { - try - { - pMap[ j ] = new sal_uInt8[ nBytesPerRow ]; - } - catch (const std::bad_alloc &) + nBytesPerRow = ( nImageWidth * nSamplesPerPixel / nPlanes * nBitsPerSample + 7 ) >> 3; + + for ( sal_uLong j = 0; j < 4; j++ ) { - pMap[ j ] = NULL; - bStatus = false; - break; + try + { + pMap[ j ] = new sal_uInt8[ nBytesPerRow ]; + } + catch (const std::bad_alloc &) + { + pMap[ j ] = NULL; + bStatus = false; + break; + } } } - if (HasAlphaChannel()) + if (bStatus && HasAlphaChannel()) { pAlphaMask = new AlphaMask( aTargetSize ); pMaskAcc = pAlphaMask->AcquireWriteAccess(); } - if ( bStatus && ReadMap( 10, 60 ) ) + if (bStatus && ReadMap(10, 60)) { nMaxPos = std::max( pTIFF->Tell(), nMaxPos ); MakePalCol();
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits