diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-08-19 15:14:04 +0100 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2014-08-20 03:23:24 -0500 |
commit | 3bcdd9fc24a9bec2997768c6aa7a78a0c1f329ee (patch) | |
tree | 518b4f57498e2d03ef8ade45d9ce40a97d62064e /filter | |
parent | c0aedce4e6f5393eb31a88a24a5f25cd5cf21142 (diff) |
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 <dtardon@redhat.com>
Tested-by: David Tardon <dtardon@redhat.com>
Diffstat (limited to 'filter')
-rw-r--r-- | filter/source/graphicfilter/itiff/itiff.cxx | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/filter/source/graphicfilter/itiff/itiff.cxx b/filter/source/graphicfilter/itiff/itiff.cxx index f708435af1e1..4122ab28385e 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(); |