[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - 2 commits - vcl/source
Caolán McNamara
caolanm at redhat.com
Tue Jan 26 01:05:35 PST 2016
vcl/source/filter/igif/gifread.cxx | 29 +++++++++++++----------------
vcl/source/filter/wmf/enhwmf.cxx | 6 +++---
vcl/source/filter/wmf/winmtf.cxx | 10 ++++------
vcl/source/filter/wmf/winmtf.hxx | 2 +-
vcl/source/filter/wmf/winwmf.cxx | 4 ++--
5 files changed, 23 insertions(+), 28 deletions(-)
New commits:
commit 6fed035cf1eb62db8029e615e1b5f2d3ab825f78
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Jan 21 09:28:12 2016 +0000
valgrind: memleak on thrown exception
(cherry picked from commit f5aefab2a62a90c631e05ec29022a2f7e19f00c3)
Change-Id: I2788c5fe04a984d6534adbd3186cc652685152e8
Reviewed-on: https://gerrit.libreoffice.org/21737
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: David Tardon <dtardon at redhat.com>
(cherry picked from commit 636d45438f317d7ef39d660c11f6bab1dc42302a)
diff --git a/vcl/source/filter/wmf/enhwmf.cxx b/vcl/source/filter/wmf/enhwmf.cxx
index bb029b5..dfc7790 100644
--- a/vcl/source/filter/wmf/enhwmf.cxx
+++ b/vcl/source/filter/wmf/enhwmf.cxx
@@ -1244,7 +1244,7 @@ bool EnhWMFReader::ReadEnhWMF()
Rectangle aCropRect( Point( xSrc, ySrc ), Size( cxSrc, cySrc ) );
aBitmap.Crop( aCropRect );
}
- aBmpSaveList.push_back( new BSaveStruct( aBitmap, aRect, dwRop, pOut->GetFillStyle () ) );
+ aBmpSaveList.emplace_back(new BSaveStruct(aBitmap, aRect, dwRop, pOut->GetFillStyle ()));
}
}
}
@@ -1305,7 +1305,7 @@ bool EnhWMFReader::ReadEnhWMF()
Rectangle aCropRect( Point( xSrc, ySrc ), Size( cxSrc, cySrc ) );
aBitmap.Crop( aCropRect );
}
- aBmpSaveList.push_back( new BSaveStruct( aBitmap, aRect, dwRop, pOut->GetFillStyle () ) );
+ aBmpSaveList.emplace_back(new BSaveStruct(aBitmap, aRect, dwRop, pOut->GetFillStyle ()));
}
}
}
@@ -1372,7 +1372,7 @@ bool EnhWMFReader::ReadEnhWMF()
Rectangle aCropRect( Point( xSrc, ySrc ), Size( cxSrc, cySrc ) );
aBitmap.Crop( aCropRect );
}
- aBmpSaveList.push_back( new BSaveStruct( aBitmap, aRect, dwRop, pOut->GetFillStyle () ) );
+ aBmpSaveList.emplace_back(new BSaveStruct(aBitmap, aRect, dwRop, pOut->GetFillStyle ()));
}
}
}
diff --git a/vcl/source/filter/wmf/winmtf.cxx b/vcl/source/filter/wmf/winmtf.cxx
index c19642a..3f71773 100644
--- a/vcl/source/filter/wmf/winmtf.cxx
+++ b/vcl/source/filter/wmf/winmtf.cxx
@@ -1576,7 +1576,7 @@ void WinMtfOutput::ResolveBitmapActions( BSaveStructList_impl& rSaveList )
size_t nObjectsOfSameSize = 0;
size_t nObjectStartIndex = nObjects - nObjectsLeft;
- BSaveStruct* pSave = rSaveList[ nObjectStartIndex ];
+ BSaveStruct* pSave = rSaveList[nObjectStartIndex].get();
Rectangle aRect( pSave->aOutRect );
for ( i = nObjectStartIndex; i < nObjects; )
@@ -1584,7 +1584,7 @@ void WinMtfOutput::ResolveBitmapActions( BSaveStructList_impl& rSaveList )
nObjectsOfSameSize++;
if ( ++i < nObjects )
{
- pSave = rSaveList[ i ];
+ pSave = rSaveList[i].get();
if ( pSave->aOutRect != aRect )
break;
}
@@ -1594,7 +1594,7 @@ void WinMtfOutput::ResolveBitmapActions( BSaveStructList_impl& rSaveList )
for ( i = nObjectStartIndex; i < ( nObjectStartIndex + nObjectsOfSameSize ); i++ )
{
- pSave = rSaveList[ i ];
+ pSave = rSaveList[i].get();
sal_uInt32 nWinRop = pSave->nWinRop;
sal_uInt8 nRasterOperation = (sal_uInt8)( nWinRop >> 16 );
@@ -1622,7 +1622,7 @@ void WinMtfOutput::ResolveBitmapActions( BSaveStructList_impl& rSaveList )
{
if ( nObjectsOfSameSize == 2 )
{
- BSaveStruct* pSave2 = rSaveList[ i + 1 ];
+ BSaveStruct* pSave2 = rSaveList[i + 1].get();
if ( ( pSave->aBmp.GetPrefSize() == pSave2->aBmp.GetPrefSize() ) &&
( pSave->aBmp.GetPrefMapMode() == pSave2->aBmp.GetPrefMapMode() ) )
{
@@ -1791,8 +1791,6 @@ void WinMtfOutput::ResolveBitmapActions( BSaveStructList_impl& rSaveList )
nObjectsLeft -= nObjectsOfSameSize;
}
- for( size_t i = 0, n = rSaveList.size(); i < n; ++i )
- delete rSaveList[ i ];
rSaveList.clear();
}
diff --git a/vcl/source/filter/wmf/winmtf.hxx b/vcl/source/filter/wmf/winmtf.hxx
index 087c3f2..0a0cf3d 100644
--- a/vcl/source/filter/wmf/winmtf.hxx
+++ b/vcl/source/filter/wmf/winmtf.hxx
@@ -470,7 +470,7 @@ struct BSaveStruct
{}
};
-typedef ::std::vector< BSaveStruct* > BSaveStructList_impl;
+typedef std::vector<std::unique_ptr<BSaveStruct>> BSaveStructList_impl;
enum GDIObjectType
{
diff --git a/vcl/source/filter/wmf/winwmf.cxx b/vcl/source/filter/wmf/winwmf.cxx
index 64508ef..1b590e4 100644
--- a/vcl/source/filter/wmf/winwmf.cxx
+++ b/vcl/source/filter/wmf/winwmf.cxx
@@ -680,7 +680,7 @@ void WMFReader::ReadRecordParams( sal_uInt16 nFunc )
aBmp.Crop( aCropRect );
}
Rectangle aDestRect( aPoint, Size( nSxe, nSye ) );
- aBmpSaveList.push_back( new BSaveStruct( aBmp, aDestRect, nWinROP, pOut->GetFillStyle () ) );
+ aBmpSaveList.emplace_back(new BSaveStruct(aBmp, aDestRect, nWinROP, pOut->GetFillStyle ()));
}
}
}
@@ -730,7 +730,7 @@ void WMFReader::ReadRecordParams( sal_uInt16 nFunc )
Rectangle aCropRect( Point( nSx, nSy ), Size( nSxe, nSye ) );
aBmp.Crop( aCropRect );
}
- aBmpSaveList.push_back( new BSaveStruct( aBmp, aDestRect, nWinROP, pOut->GetFillStyle () ) );
+ aBmpSaveList.emplace_back(new BSaveStruct(aBmp, aDestRect, nWinROP, pOut->GetFillStyle ()));
}
}
}
commit a9e35171cfcb741c221151f6fd9c0026349f6f76
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Jan 21 09:54:29 2016 +0000
valgrind: memleak on thrown exception
(cherry picked from commit 15b1080e624447ca1af1396023bb1fbfdb44fb26)
Reviewed-on: https://gerrit.libreoffice.org/21736
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: David Tardon <dtardon at redhat.com>
(cherry picked from commit 85918431993fe3637145cca62b133c0c21cb5430)
Change-Id: If562dc69290021f898feff9f8e3983b867075172
diff --git a/vcl/source/filter/igif/gifread.cxx b/vcl/source/filter/igif/gifread.cxx
index cb0e0ee..9b4d690 100644
--- a/vcl/source/filter/igif/gifread.cxx
+++ b/vcl/source/filter/igif/gifread.cxx
@@ -804,33 +804,30 @@ ReadState GIFReader::ReadGIF( Graphic& rGraphic )
VCL_DLLPUBLIC bool ImportGIF( SvStream & rStm, Graphic& rGraphic )
{
- GIFReader* pGIFReader = static_cast<GIFReader*>(rGraphic.GetContext());
- SvStreamEndian nOldFormat = rStm.GetEndian();
- ReadState eReadState;
- bool bRet = true;
+ std::unique_ptr<GIFReader> xGIFReader(static_cast<GIFReader*>(rGraphic.GetContext()));
+ rGraphic.SetContext(nullptr);
+ SvStreamEndian nOldFormat = rStm.GetEndian();
rStm.SetEndian( SvStreamEndian::LITTLE );
- if( !pGIFReader )
- pGIFReader = new GIFReader( rStm );
+ if (!xGIFReader)
+ xGIFReader.reset(new GIFReader(rStm));
- rGraphic.SetContext( nullptr );
- eReadState = pGIFReader->ReadGIF( rGraphic );
+ bool bRet = true;
- if( eReadState == GIFREAD_ERROR )
+ ReadState eReadState = xGIFReader->ReadGIF(rGraphic);
+
+ if (eReadState == GIFREAD_ERROR)
{
bRet = false;
- delete pGIFReader;
}
- else if( eReadState == GIFREAD_OK )
- delete pGIFReader;
- else
+ else if (eReadState == GIFREAD_NEED_MORE)
{
- rGraphic = pGIFReader->GetIntermediateGraphic();
- rGraphic.SetContext( pGIFReader );
+ rGraphic = xGIFReader->GetIntermediateGraphic();
+ rGraphic.SetContext(xGIFReader.release());
}
- rStm.SetEndian( nOldFormat );
+ rStm.SetEndian(nOldFormat);
return bRet;
}
More information about the Libreoffice-commits
mailing list