Kaydet (Commit) 1ab0e871 authored tarafından Caolán McNamara's avatar Caolán McNamara

guard against division by 0

valgrind + bff

Change-Id: I5fa40f7a9759c98bb70ee6eb854dd9b376401f89
üst 44afb981
...@@ -1324,29 +1324,34 @@ bool TIFFReader::ReadTIFF(SvStream & rTIFF, Graphic & rGraphic ) ...@@ -1324,29 +1324,34 @@ bool TIFFReader::ReadTIFF(SvStream & rTIFF, Graphic & rGraphic )
bByteSwap = true; bByteSwap = true;
nStripsPerPlane = ( nImageLength - 1 ) / GetRowsPerStrip() + 1; 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 nBytesPerRow = ( nImageWidth * nSamplesPerPixel / nPlanes * nBitsPerSample + 7 ) >> 3;
{
pMap[ j ] = new sal_uInt8[ nBytesPerRow ]; for ( sal_uLong j = 0; j < 4; j++ )
}
catch (const std::bad_alloc &)
{ {
pMap[ j ] = NULL; try
bStatus = false; {
break; 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 ); pAlphaMask = new AlphaMask( aTargetSize );
pMaskAcc = pAlphaMask->AcquireWriteAccess(); pMaskAcc = pAlphaMask->AcquireWriteAccess();
} }
if ( bStatus && ReadMap( 10, 60 ) ) if (bStatus && ReadMap(10, 60))
{ {
nMaxPos = std::max( pTIFF->Tell(), nMaxPos ); nMaxPos = std::max( pTIFF->Tell(), nMaxPos );
MakePalCol(); MakePalCol();
......
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