[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - filter/source
Caolán McNamara
caolanm at redhat.com
Wed Aug 20 01:24:11 PDT 2014
filter/source/graphicfilter/itiff/itiff.cxx | 29 ++++++++++++++++------------
1 file changed, 17 insertions(+), 12 deletions(-)
New commits:
commit 9485833fb89f86b7ac9c4de14b116ca6cf3f8faf
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue Aug 19 15:14:04 2014 +0100
guard against division by 0
valgrind + bff
(cherry picked from commit 1ab0e8717bee9fee6c42015647bccfbf1683b8fc)
Conflicts:
filter/source/graphicfilter/itiff/itiff.cxx
Change-Id: I5fa40f7a9759c98bb70ee6eb854dd9b376401f89
Reviewed-on: https://gerrit.libreoffice.org/11037
Reviewed-by: David Tardon <dtardon at redhat.com>
Tested-by: David Tardon <dtardon at redhat.com>
diff --git a/filter/source/graphicfilter/itiff/itiff.cxx b/filter/source/graphicfilter/itiff/itiff.cxx
index a921b53..aa80b09 100644
--- a/filter/source/graphicfilter/itiff/itiff.cxx
+++ b/filter/source/graphicfilter/itiff/itiff.cxx
@@ -1332,29 +1332,34 @@ sal_Bool TIFFReader::ReadTIFF(SvStream & rTIFF, Graphic & rGraphic )
bByteSwap = sal_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 = sal_False;
- break;
+ try
+ {
+ pMap[ j ] = new sal_uInt8[ nBytesPerRow ];
+ }
+ catch (const std::bad_alloc &)
+ {
+ pMap[ j ] = NULL;
+ bStatus = sal_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();
More information about the Libreoffice-commits
mailing list