From d025ffdf14c3ea1e76426d1d5c499a7c07ed2622 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Jan 23 2016 20:44:33 +0000 Subject: fix some leaks --- diff --git a/0001-valgrind-memleak-on-thrown-exception.patch b/0001-valgrind-memleak-on-thrown-exception.patch new file mode 100644 index 0000000..334b331 --- /dev/null +++ b/0001-valgrind-memleak-on-thrown-exception.patch @@ -0,0 +1,66 @@ +From c27f68451faba2b4c1c39feab2a76acfa0c3d1b5 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= +Date: Thu, 21 Jan 2016 09:54:29 +0000 +Subject: [PATCH 1/2] valgrind: memleak on thrown exception + +(cherry picked from commit 15b1080e624447ca1af1396023bb1fbfdb44fb26) + +Change-Id: If562dc69290021f898feff9f8e3983b867075172 +--- + vcl/source/filter/igif/gifread.cxx | 29 +++++++++++++---------------- + 1 file changed, 13 insertions(+), 16 deletions(-) + +diff --git a/vcl/source/filter/igif/gifread.cxx b/vcl/source/filter/igif/gifread.cxx +index 3526a0b..1e8daf9 100644 +--- a/vcl/source/filter/igif/gifread.cxx ++++ b/vcl/source/filter/igif/gifread.cxx +@@ -804,33 +804,30 @@ ReadState GIFReader::ReadGIF( Graphic& rGraphic ) + + bool ImportGIF( SvStream & rStm, Graphic& rGraphic ) + { +- GIFReader* pGIFReader = static_cast(rGraphic.GetContext()); +- SvStreamEndian nOldFormat = rStm.GetEndian(); +- ReadState eReadState; +- bool bRet = true; ++ std::unique_ptr xGIFReader(static_cast(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( NULL ); +- 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; + } +-- +2.5.0 + diff --git a/0002-valgrind-memleak-on-thrown-exception.patch b/0002-valgrind-memleak-on-thrown-exception.patch new file mode 100644 index 0000000..a7c25a7 --- /dev/null +++ b/0002-valgrind-memleak-on-thrown-exception.patch @@ -0,0 +1,133 @@ +From 230a171d6e25bb33e9a30566d4a22952b652b9c7 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= +Date: Thu, 21 Jan 2016 09:28:12 +0000 +Subject: [PATCH 2/2] valgrind: memleak on thrown exception + +(cherry picked from commit f5aefab2a62a90c631e05ec29022a2f7e19f00c3) + +Change-Id: I2788c5fe04a984d6534adbd3186cc652685152e8 +--- + 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 ++-- + 4 files changed, 10 insertions(+), 12 deletions(-) + +diff --git a/vcl/source/filter/wmf/enhwmf.cxx b/vcl/source/filter/wmf/enhwmf.cxx +index a59d684..f130fad 100644 +--- a/vcl/source/filter/wmf/enhwmf.cxx ++++ b/vcl/source/filter/wmf/enhwmf.cxx +@@ -1239,7 +1239,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 ())); + } + } + } +@@ -1303,7 +1303,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 ())); + } + } + } +@@ -1373,7 +1373,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 513751d..b2ae7dc 100644 +--- a/vcl/source/filter/wmf/winmtf.cxx ++++ b/vcl/source/filter/wmf/winmtf.cxx +@@ -1577,7 +1577,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; ) +@@ -1585,7 +1585,7 @@ void WinMtfOutput::ResolveBitmapActions( BSaveStructList_impl& rSaveList ) + nObjectsOfSameSize++; + if ( ++i < nObjects ) + { +- pSave = rSaveList[ i ]; ++ pSave = rSaveList[i].get(); + if ( pSave->aOutRect != aRect ) + break; + } +@@ -1595,7 +1595,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 ); +@@ -1623,7 +1623,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() ) ) + { +@@ -1792,8 +1792,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 3b78821..dd35561 100644 +--- a/vcl/source/filter/wmf/winmtf.hxx ++++ b/vcl/source/filter/wmf/winmtf.hxx +@@ -471,7 +471,7 @@ struct BSaveStruct + {} + }; + +-typedef ::std::vector< BSaveStruct* > BSaveStructList_impl; ++typedef std::vector> BSaveStructList_impl; + + enum GDIObjectType + { +diff --git a/vcl/source/filter/wmf/winwmf.cxx b/vcl/source/filter/wmf/winwmf.cxx +index 1f4cd7d..04e5535 100644 +--- a/vcl/source/filter/wmf/winwmf.cxx ++++ b/vcl/source/filter/wmf/winwmf.cxx +@@ -676,7 +676,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 ())); + } + } + } +@@ -726,7 +726,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 ())); + } + } + } +-- +2.5.0 + diff --git a/libreoffice.spec b/libreoffice.spec index 70926ad..a8318d0 100644 --- a/libreoffice.spec +++ b/libreoffice.spec @@ -374,6 +374,8 @@ Patch65: 0002-Fix-memleak-of-strings-allocated-in-VclGtkClipboard-.patch Patch66: 0003-Resolves-rhbz-1240591-gtk3-store-clipboard-when-Libr.patch Patch67: 0001-Resolves-rhbz-1257635-after-httpConnectEncrypt-use-c.patch Patch68: 0001-rerun-autoconf-after-remove-BOOST_SYSTEM.patch +Patch69: 0001-valgrind-memleak-on-thrown-exception.patch +Patch70: 0002-valgrind-memleak-on-thrown-exception.patch %define instdir %{_libdir} %define baseinstdir %{instdir}/libreoffice