diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2007-11-01 14:02:39 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2007-11-01 14:02:39 +0000 |
commit | 017cc68468d723bc2364c1a30b2705053252d7ad (patch) | |
tree | abed7dc98b8a521649d46ba6b219cfde420b7a6f /svtools | |
parent | INTEGRATION: CWS thbpp9_SRC680 (1.2.84); FILE MERGED (diff) | |
download | core-017cc68468d723bc2364c1a30b2705053252d7ad.tar.gz core-017cc68468d723bc2364c1a30b2705053252d7ad.zip |
INTEGRATION: CWS pmladek07_SRC680 (1.70.14); FILE MERGED
2007/10/25 11:16:23 pmladek 1.70.14.1: #i82970#
Do not crash when loading too big pictures
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/filter.vcl/filter/filter.cxx | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/svtools/source/filter.vcl/filter/filter.cxx b/svtools/source/filter.vcl/filter/filter.cxx index 201cabe773a7..194dceabd1d9 100644 --- a/svtools/source/filter.vcl/filter/filter.cxx +++ b/svtools/source/filter.vcl/filter/filter.cxx @@ -4,9 +4,9 @@ * * $RCSfile: filter.cxx,v $ * - * $Revision: 1.71 $ + * $Revision: 1.72 $ * - * last change: $Author: kz $ $Date: 2007-09-06 14:12:48 $ + * last change: $Author: hr $ $Date: 2007-11-01 15:02:39 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -1648,6 +1648,33 @@ USHORT GraphicFilter::ImportGraphic( Graphic& rGraphic, const String& rPath, SvS } } } + + if( nStatus == GRFILTER_OK && bCreateNativeLink && ( eLinkType != GFX_LINK_TYPE_NONE ) && !rGraphic.GetContext() && !bLinkSet ) + { + const ULONG nStmEnd = rIStream.Tell(); + const ULONG nBufSize = nStmEnd - nStmBegin; + + if( nBufSize ) + { + BYTE* pBuf; + try + { + pBuf = new BYTE[ nBufSize ]; + } + catch (std::bad_alloc) + { + nStatus = GRFILTER_TOOBIG; + } + + if( nStatus == GRFILTER_OK ) + { + rIStream.Seek( nStmBegin ); + rIStream.Read( pBuf, nBufSize ); + rGraphic.SetLink( GfxLink( pBuf, nBufSize, eLinkType, TRUE ) ); + } + } + } + // Set error code or try to set native buffer if( nStatus != GRFILTER_OK ) { @@ -1658,21 +1685,7 @@ USHORT GraphicFilter::ImportGraphic( Graphic& rGraphic, const String& rPath, SvS rIStream.Seek( nStmBegin ); rGraphic.Clear(); } - else if( bCreateNativeLink && ( eLinkType != GFX_LINK_TYPE_NONE ) && !rGraphic.GetContext() && !bLinkSet ) - { - const ULONG nStmEnd = rIStream.Tell(); - const ULONG nBufSize = nStmEnd - nStmBegin; - if( nBufSize ) - { - BYTE* pBuf = new BYTE[ nBufSize ]; - //GraphicReader* pOldContext = rGraphic.GetContext(); - - rIStream.Seek( nStmBegin ); - rIStream.Read( pBuf, nBufSize ); - rGraphic.SetLink( GfxLink( pBuf, nBufSize, eLinkType, TRUE ) ); - } - } delete pFilterConfigItem; return nStatus; } |