[Libreoffice-commits] core.git: 2 commits - vcl/source
Caolán McNamara
caolanm at redhat.com
Mon Feb 13 10:42:32 UTC 2017
vcl/source/gdi/gdimtf.cxx | 42 ++++++++++++++++++++++++------------------
1 file changed, 24 insertions(+), 18 deletions(-)
New commits:
commit aec27009c732d19764423ec41c231bb945dbd728
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon Feb 13 10:41:08 2017 +0000
Resolves: ofz#584 don't terminate on bad fraction exception
Change-Id: Icf6c7a29ad129550fbc533c3af2b77fe7e91ce26
diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx
index dc48275..320e9a1 100644
--- a/vcl/source/gdi/gdimtf.cxx
+++ b/vcl/source/gdi/gdimtf.cxx
@@ -2672,54 +2672,62 @@ SvStream& ReadGDIMetaFile( SvStream& rIStm, GDIMetaFile& rGDIMetaFile )
return rIStm;
}
- char aId[ 7 ];
sal_uLong nStmPos = rIStm.Tell();
SvStreamEndian nOldFormat = rIStm.GetEndian();
rIStm.SetEndian( SvStreamEndian::LITTLE );
- aId[ 0 ] = 0;
- aId[ 6 ] = 0;
- rIStm.ReadBytes( aId, 6 );
-
- if ( !strcmp( aId, "VCLMTF" ) )
+ try
{
- // new format
- sal_uInt32 nStmCompressMode = 0;
- sal_uInt32 nCount = 0;
- std::unique_ptr<VersionCompat> pCompat(new VersionCompat( rIStm, StreamMode::READ ));
+ char aId[7];
+ aId[0] = 0;
+ aId[6] = 0;
+ rIStm.ReadBytes( aId, 6 );
- rIStm.ReadUInt32( nStmCompressMode );
- ReadMapMode( rIStm, rGDIMetaFile.m_aPrefMapMode );
- ReadPair( rIStm, rGDIMetaFile.m_aPrefSize );
- rIStm.ReadUInt32( nCount );
+ if ( !strcmp( aId, "VCLMTF" ) )
+ {
+ // new format
+ sal_uInt32 nStmCompressMode = 0;
+ sal_uInt32 nCount = 0;
+ std::unique_ptr<VersionCompat> pCompat(new VersionCompat( rIStm, StreamMode::READ ));
- pCompat.reset(); // destructor writes stuff into the header
+ rIStm.ReadUInt32( nStmCompressMode );
+ ReadMapMode( rIStm, rGDIMetaFile.m_aPrefMapMode );
+ ReadPair( rIStm, rGDIMetaFile.m_aPrefSize );
+ rIStm.ReadUInt32( nCount );
- ImplMetaReadData aReadData;
- aReadData.meActualCharSet = rIStm.GetStreamCharSet();
+ pCompat.reset(); // destructor writes stuff into the header
- for( sal_uInt32 nAction = 0UL; ( nAction < nCount ) && !rIStm.IsEof(); nAction++ )
- {
- MetaAction* pAction = MetaAction::ReadMetaAction( rIStm, &aReadData );
- if( pAction )
+ ImplMetaReadData aReadData;
+ aReadData.meActualCharSet = rIStm.GetStreamCharSet();
+
+ for( sal_uInt32 nAction = 0UL; ( nAction < nCount ) && !rIStm.IsEof(); nAction++ )
{
- if (pAction->GetType() == MetaActionType::COMMENT)
+ MetaAction* pAction = MetaAction::ReadMetaAction( rIStm, &aReadData );
+ if( pAction )
{
- MetaCommentAction* pCommentAct = static_cast<MetaCommentAction*>(pAction);
- if ( pCommentAct->GetComment() == "EMF_PLUS" )
- rGDIMetaFile.UseCanvas( true );
+ if (pAction->GetType() == MetaActionType::COMMENT)
+ {
+ MetaCommentAction* pCommentAct = static_cast<MetaCommentAction*>(pAction);
+ if ( pCommentAct->GetComment() == "EMF_PLUS" )
+ rGDIMetaFile.UseCanvas( true );
+ }
+ rGDIMetaFile.AddAction( pAction );
}
- rGDIMetaFile.AddAction( pAction );
}
}
+ else
+ {
+ // to avoid possible compiler optimizations => new/delete
+ rIStm.Seek( nStmPos );
+ delete( new SVMConverter( rIStm, rGDIMetaFile, CONVERT_FROM_SVM1 ) );
+ }
}
- else
+ catch (...)
{
- // to avoid possible compiler optimizations => new/delete
- rIStm.Seek( nStmPos );
- delete( new SVMConverter( rIStm, rGDIMetaFile, CONVERT_FROM_SVM1 ) );
- }
+ SAL_WARN("vcl", "GDIMetaFile exception during load");
+ rIStm.SetError(SVSTREAM_FILEFORMAT_ERROR);
+ };
// check for errors
if( rIStm.GetError() )
commit a9f5140ed087961dbb951da87c040b049bc4e464
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon Feb 13 10:31:00 2017 +0000
return early on error
no logic change intended
Change-Id: I26558d743f1ab6c3d7b42179fe44f06a786806b6
diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx
index 1604103..dc48275 100644
--- a/vcl/source/gdi/gdimtf.cxx
+++ b/vcl/source/gdi/gdimtf.cxx
@@ -2666,71 +2666,69 @@ sal_uLong GDIMetaFile::GetSizeBytes() const
SvStream& ReadGDIMetaFile( SvStream& rIStm, GDIMetaFile& rGDIMetaFile )
{
- if( !rIStm.GetError() )
+ if (rIStm.GetError())
{
- char aId[ 7 ];
- sal_uLong nStmPos = rIStm.Tell();
- SvStreamEndian nOldFormat = rIStm.GetEndian();
+ SAL_WARN("vcl.gdi", "Stream error: " << rIStm.GetError());
+ return rIStm;
+ }
- rIStm.SetEndian( SvStreamEndian::LITTLE );
+ char aId[ 7 ];
+ sal_uLong nStmPos = rIStm.Tell();
+ SvStreamEndian nOldFormat = rIStm.GetEndian();
- aId[ 0 ] = 0;
- aId[ 6 ] = 0;
- rIStm.ReadBytes( aId, 6 );
+ rIStm.SetEndian( SvStreamEndian::LITTLE );
- if ( !strcmp( aId, "VCLMTF" ) )
- {
- // new format
- sal_uInt32 nStmCompressMode = 0;
- sal_uInt32 nCount = 0;
- std::unique_ptr<VersionCompat> pCompat(new VersionCompat( rIStm, StreamMode::READ ));
+ aId[ 0 ] = 0;
+ aId[ 6 ] = 0;
+ rIStm.ReadBytes( aId, 6 );
- rIStm.ReadUInt32( nStmCompressMode );
- ReadMapMode( rIStm, rGDIMetaFile.m_aPrefMapMode );
- ReadPair( rIStm, rGDIMetaFile.m_aPrefSize );
- rIStm.ReadUInt32( nCount );
+ if ( !strcmp( aId, "VCLMTF" ) )
+ {
+ // new format
+ sal_uInt32 nStmCompressMode = 0;
+ sal_uInt32 nCount = 0;
+ std::unique_ptr<VersionCompat> pCompat(new VersionCompat( rIStm, StreamMode::READ ));
+
+ rIStm.ReadUInt32( nStmCompressMode );
+ ReadMapMode( rIStm, rGDIMetaFile.m_aPrefMapMode );
+ ReadPair( rIStm, rGDIMetaFile.m_aPrefSize );
+ rIStm.ReadUInt32( nCount );
- pCompat.reset(); // destructor writes stuff into the header
+ pCompat.reset(); // destructor writes stuff into the header
- ImplMetaReadData aReadData;
- aReadData.meActualCharSet = rIStm.GetStreamCharSet();
+ ImplMetaReadData aReadData;
+ aReadData.meActualCharSet = rIStm.GetStreamCharSet();
- for( sal_uInt32 nAction = 0UL; ( nAction < nCount ) && !rIStm.IsEof(); nAction++ )
+ for( sal_uInt32 nAction = 0UL; ( nAction < nCount ) && !rIStm.IsEof(); nAction++ )
+ {
+ MetaAction* pAction = MetaAction::ReadMetaAction( rIStm, &aReadData );
+ if( pAction )
{
- MetaAction* pAction = MetaAction::ReadMetaAction( rIStm, &aReadData );
- if( pAction )
+ if (pAction->GetType() == MetaActionType::COMMENT)
{
- if (pAction->GetType() == MetaActionType::COMMENT)
- {
- MetaCommentAction* pCommentAct = static_cast<MetaCommentAction*>(pAction);
- if ( pCommentAct->GetComment() == "EMF_PLUS" )
- rGDIMetaFile.UseCanvas( true );
- }
- rGDIMetaFile.AddAction( pAction );
+ MetaCommentAction* pCommentAct = static_cast<MetaCommentAction*>(pAction);
+ if ( pCommentAct->GetComment() == "EMF_PLUS" )
+ rGDIMetaFile.UseCanvas( true );
}
+ rGDIMetaFile.AddAction( pAction );
}
}
- else
- {
- // to avoid possible compiler optimizations => new/delete
- rIStm.Seek( nStmPos );
- delete( new SVMConverter( rIStm, rGDIMetaFile, CONVERT_FROM_SVM1 ) );
- }
-
- // check for errors
- if( rIStm.GetError() )
- {
- rGDIMetaFile.Clear();
- rIStm.Seek( nStmPos );
- }
-
- rIStm.SetEndian( nOldFormat );
}
else
{
- SAL_WARN("vcl.gdi", "Stream error: " << rIStm.GetError());
+ // to avoid possible compiler optimizations => new/delete
+ rIStm.Seek( nStmPos );
+ delete( new SVMConverter( rIStm, rGDIMetaFile, CONVERT_FROM_SVM1 ) );
+ }
+
+ // check for errors
+ if( rIStm.GetError() )
+ {
+ rGDIMetaFile.Clear();
+ rIStm.Seek( nStmPos );
}
+ rIStm.SetEndian( nOldFormat );
return rIStm;
}
More information about the Libreoffice-commits
mailing list