diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2007-11-01 14:03:09 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2007-11-01 14:03:09 +0000 |
commit | 7410c0f5e4b9e0f17726b98107d4451328d65432 (patch) | |
tree | 6ac85d689cb9ee5c29de16399d32a2897c307e6b /goodies | |
parent | 017cc68468d723bc2364c1a30b2705053252d7ad (diff) |
INTEGRATION: CWS pmladek07_SRC680 (1.14.18); FILE MERGED
2007/10/25 11:16:23 pmladek 1.14.18.1: #i82970#
Do not crash when loading too big pictures
Diffstat (limited to 'goodies')
-rw-r--r-- | goodies/source/filter.vcl/itiff/itiff.cxx | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/goodies/source/filter.vcl/itiff/itiff.cxx b/goodies/source/filter.vcl/itiff/itiff.cxx index f565aa527d3c..ed4849b2c77a 100644 --- a/goodies/source/filter.vcl/itiff/itiff.cxx +++ b/goodies/source/filter.vcl/itiff/itiff.cxx @@ -4,9 +4,9 @@ * * $RCSfile: itiff.cxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * - * last change: $Author: hr $ $Date: 2007-08-01 12:39:29 $ + * last change: $Author: hr $ $Date: 2007-11-01 15:03:09 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -360,10 +360,16 @@ void TIFFReader::ReadTagData( USHORT nTagType, sal_uInt32 nDataLen) if ( ( nDataLen > nOldNumSO ) && ( nDataLen < SAL_MAX_UINT32 / sizeof( sal_uInt32 ) ) ) { nNumStripOffsets = nDataLen; - pStripOffsets = new ULONG[ nNumStripOffsets ]; - if ( !pStripOffsets ) + try + { + pStripOffsets = new ULONG[ nNumStripOffsets ]; + } + catch (std::bad_alloc) + { + pStripOffsets = NULL; nNumStripOffsets = 0; - else + } + if ( pStripOffsets ) { for ( i = 0; i < nOldNumSO; i++ ) pStripOffsets[ i ] = pOldSO[ i ] + nOrigPos; @@ -400,10 +406,16 @@ void TIFFReader::ReadTagData( USHORT nTagType, sal_uInt32 nDataLen) if ( ( nDataLen > nOldNumSBC ) && ( nDataLen < SAL_MAX_UINT32 / sizeof( sal_uInt32 ) ) ) { nNumStripByteCounts = nDataLen; - pStripByteCounts = new ULONG[ nNumStripByteCounts ]; - if ( !nNumStripByteCounts ) + try + { + pStripByteCounts = new ULONG[ nNumStripByteCounts ]; + } + catch (std::bad_alloc) + { + pStripByteCounts = NULL; nNumStripByteCounts = 0; - else + } + if ( pStripByteCounts ) { for ( i = 0; i < nOldNumSBC; i++ ) pStripByteCounts[ i ] = pOldSBC[ i ]; @@ -1240,9 +1252,20 @@ BOOL TIFFReader::ReadTIFF(SvStream & rTIFF, Graphic & rGraphic ) nBytesPerRow = ( nImageWidth * nSamplesPerPixel / nPlanes * nBitsPerSample + 7 ) >> 3; for ( ULONG j = 0; j < 4; j++ ) - pMap[ j ] = new BYTE[ nBytesPerRow ]; + { + try + { + pMap[ j ] = new BYTE[ nBytesPerRow ]; + } + catch (std::bad_alloc) + { + pMap[ j ] = NULL; + bStatus = FALSE; + break; + } + } - if ( ReadMap( 10, 60 ) ) + if ( bStatus && ReadMap( 10, 60 ) ) { nMaxPos = Max( pTIFF->Tell(), nMaxPos ); MakePalCol(); |