summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-08-19 15:14:04 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-08-19 15:22:13 +0100
commit1ab0e8717bee9fee6c42015647bccfbf1683b8fc (patch)
tree97773e9f83c3b8ed25e0017180fd4451b5a618bc /filter
parent44afb981a587fb5b5e6fd9ba5c5b138526cfb04b (diff)
guard against division by 0
valgrind + bff Change-Id: I5fa40f7a9759c98bb70ee6eb854dd9b376401f89
Diffstat (limited to 'filter')
-rw-r--r--filter/source/graphicfilter/itiff/itiff.cxx29
1 files changed, 17 insertions, 12 deletions
diff --git a/filter/source/graphicfilter/itiff/itiff.cxx b/filter/source/graphicfilter/itiff/itiff.cxx
index 1eb4c8a60756..b588aa2be051 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();