d025ffd
From 230a171d6e25bb33e9a30566d4a22952b652b9c7 Mon Sep 17 00:00:00 2001
d025ffd
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
d025ffd
Date: Thu, 21 Jan 2016 09:28:12 +0000
d025ffd
Subject: [PATCH 2/2] valgrind: memleak on thrown exception
d025ffd
d025ffd
(cherry picked from commit f5aefab2a62a90c631e05ec29022a2f7e19f00c3)
d025ffd
d025ffd
Change-Id: I2788c5fe04a984d6534adbd3186cc652685152e8
d025ffd
---
d025ffd
 vcl/source/filter/wmf/enhwmf.cxx |  6 +++---
d025ffd
 vcl/source/filter/wmf/winmtf.cxx | 10 ++++------
d025ffd
 vcl/source/filter/wmf/winmtf.hxx |  2 +-
d025ffd
 vcl/source/filter/wmf/winwmf.cxx |  4 ++--
d025ffd
 4 files changed, 10 insertions(+), 12 deletions(-)
d025ffd
d025ffd
diff --git a/vcl/source/filter/wmf/enhwmf.cxx b/vcl/source/filter/wmf/enhwmf.cxx
d025ffd
index a59d684..f130fad 100644
d025ffd
--- a/vcl/source/filter/wmf/enhwmf.cxx
d025ffd
+++ b/vcl/source/filter/wmf/enhwmf.cxx
d025ffd
@@ -1239,7 +1239,7 @@ bool EnhWMFReader::ReadEnhWMF()
d025ffd
                                 Rectangle aCropRect( Point( xSrc, ySrc ), Size( cxSrc, cySrc ) );
d025ffd
                                 aBitmap.Crop( aCropRect );
d025ffd
                             }
d025ffd
-                            aBmpSaveList.push_back( new BSaveStruct( aBitmap, aRect, dwRop, pOut->GetFillStyle () ) );
d025ffd
+                            aBmpSaveList.emplace_back(new BSaveStruct(aBitmap, aRect, dwRop, pOut->GetFillStyle ()));
d025ffd
                         }
d025ffd
                     }
d025ffd
                 }
d025ffd
@@ -1303,7 +1303,7 @@ bool EnhWMFReader::ReadEnhWMF()
d025ffd
                                 Rectangle aCropRect( Point( xSrc, ySrc ), Size( cxSrc, cySrc ) );
d025ffd
                                 aBitmap.Crop( aCropRect );
d025ffd
                             }
d025ffd
-                            aBmpSaveList.push_back( new BSaveStruct( aBitmap, aRect, dwRop, pOut->GetFillStyle () ) );
d025ffd
+                            aBmpSaveList.emplace_back(new BSaveStruct(aBitmap, aRect, dwRop, pOut->GetFillStyle ()));
d025ffd
                         }
d025ffd
                     }
d025ffd
                 }
d025ffd
@@ -1373,7 +1373,7 @@ bool EnhWMFReader::ReadEnhWMF()
d025ffd
                                 Rectangle aCropRect( Point( xSrc, ySrc ), Size( cxSrc, cySrc ) );
d025ffd
                                 aBitmap.Crop( aCropRect );
d025ffd
                             }
d025ffd
-                        aBmpSaveList.push_back( new BSaveStruct( aBitmap, aRect, dwRop, pOut->GetFillStyle () ) );
d025ffd
+                            aBmpSaveList.emplace_back(new BSaveStruct(aBitmap, aRect, dwRop, pOut->GetFillStyle ()));
d025ffd
                         }
d025ffd
                     }
d025ffd
                 }
d025ffd
diff --git a/vcl/source/filter/wmf/winmtf.cxx b/vcl/source/filter/wmf/winmtf.cxx
d025ffd
index 513751d..b2ae7dc 100644
d025ffd
--- a/vcl/source/filter/wmf/winmtf.cxx
d025ffd
+++ b/vcl/source/filter/wmf/winmtf.cxx
d025ffd
@@ -1577,7 +1577,7 @@ void WinMtfOutput::ResolveBitmapActions( BSaveStructList_impl& rSaveList )
d025ffd
         size_t          nObjectsOfSameSize = 0;
d025ffd
         size_t          nObjectStartIndex = nObjects - nObjectsLeft;
d025ffd
 
d025ffd
-        BSaveStruct*    pSave = rSaveList[ nObjectStartIndex ];
d025ffd
+        BSaveStruct*    pSave = rSaveList[nObjectStartIndex].get();
d025ffd
         Rectangle       aRect( pSave->aOutRect );
d025ffd
 
d025ffd
         for ( i = nObjectStartIndex; i < nObjects; )
d025ffd
@@ -1585,7 +1585,7 @@ void WinMtfOutput::ResolveBitmapActions( BSaveStructList_impl& rSaveList )
d025ffd
             nObjectsOfSameSize++;
d025ffd
             if ( ++i < nObjects )
d025ffd
             {
d025ffd
-                pSave = rSaveList[ i ];
d025ffd
+                pSave = rSaveList[i].get();
d025ffd
                 if ( pSave->aOutRect != aRect )
d025ffd
                     break;
d025ffd
             }
d025ffd
@@ -1595,7 +1595,7 @@ void WinMtfOutput::ResolveBitmapActions( BSaveStructList_impl& rSaveList )
d025ffd
 
d025ffd
         for ( i = nObjectStartIndex; i < ( nObjectStartIndex + nObjectsOfSameSize ); i++ )
d025ffd
         {
d025ffd
-            pSave = rSaveList[ i ];
d025ffd
+            pSave = rSaveList[i].get();
d025ffd
 
d025ffd
             sal_uInt32  nWinRop = pSave->nWinRop;
d025ffd
             sal_uInt8   nRasterOperation = (sal_uInt8)( nWinRop >> 16 );
d025ffd
@@ -1623,7 +1623,7 @@ void WinMtfOutput::ResolveBitmapActions( BSaveStructList_impl& rSaveList )
d025ffd
                 {
d025ffd
                     if ( nObjectsOfSameSize == 2 )
d025ffd
                     {
d025ffd
-                        BSaveStruct* pSave2 = rSaveList[ i + 1 ];
d025ffd
+                        BSaveStruct* pSave2 = rSaveList[i + 1].get();
d025ffd
                         if ( ( pSave->aBmp.GetPrefSize() == pSave2->aBmp.GetPrefSize() ) &&
d025ffd
                              ( pSave->aBmp.GetPrefMapMode() == pSave2->aBmp.GetPrefMapMode() ) )
d025ffd
                         {
d025ffd
@@ -1792,8 +1792,6 @@ void WinMtfOutput::ResolveBitmapActions( BSaveStructList_impl& rSaveList )
d025ffd
         nObjectsLeft -= nObjectsOfSameSize;
d025ffd
     }
d025ffd
 
d025ffd
-    for( size_t i = 0, n = rSaveList.size(); i < n; ++i )
d025ffd
-        delete rSaveList[ i ];
d025ffd
     rSaveList.clear();
d025ffd
 }
d025ffd
 
d025ffd
diff --git a/vcl/source/filter/wmf/winmtf.hxx b/vcl/source/filter/wmf/winmtf.hxx
d025ffd
index 3b78821..dd35561 100644
d025ffd
--- a/vcl/source/filter/wmf/winmtf.hxx
d025ffd
+++ b/vcl/source/filter/wmf/winmtf.hxx
d025ffd
@@ -471,7 +471,7 @@ struct BSaveStruct
d025ffd
     {}
d025ffd
 };
d025ffd
 
d025ffd
-typedef ::std::vector< BSaveStruct* > BSaveStructList_impl;
d025ffd
+typedef std::vector<std::unique_ptr<BSaveStruct>> BSaveStructList_impl;
d025ffd
 
d025ffd
 enum GDIObjectType
d025ffd
 {
d025ffd
diff --git a/vcl/source/filter/wmf/winwmf.cxx b/vcl/source/filter/wmf/winwmf.cxx
d025ffd
index 1f4cd7d..04e5535 100644
d025ffd
--- a/vcl/source/filter/wmf/winwmf.cxx
d025ffd
+++ b/vcl/source/filter/wmf/winwmf.cxx
d025ffd
@@ -676,7 +676,7 @@ void WMFReader::ReadRecordParams( sal_uInt16 nFunc )
d025ffd
                         aBmp.Crop( aCropRect );
d025ffd
                     }
d025ffd
                     Rectangle aDestRect( aPoint, Size( nSxe, nSye ) );
d025ffd
-                    aBmpSaveList.push_back( new BSaveStruct( aBmp, aDestRect, nWinROP, pOut->GetFillStyle () ) );
d025ffd
+                    aBmpSaveList.emplace_back(new BSaveStruct(aBmp, aDestRect, nWinROP, pOut->GetFillStyle ()));
d025ffd
                 }
d025ffd
             }
d025ffd
         }
d025ffd
@@ -726,7 +726,7 @@ void WMFReader::ReadRecordParams( sal_uInt16 nFunc )
d025ffd
                         Rectangle aCropRect( Point( nSx, nSy ), Size( nSxe, nSye ) );
d025ffd
                         aBmp.Crop( aCropRect );
d025ffd
                     }
d025ffd
-                    aBmpSaveList.push_back( new BSaveStruct( aBmp, aDestRect, nWinROP, pOut->GetFillStyle () ) );
d025ffd
+                    aBmpSaveList.emplace_back(new BSaveStruct(aBmp, aDestRect, nWinROP, pOut->GetFillStyle ()));
d025ffd
                 }
d025ffd
             }
d025ffd
         }
d025ffd
-- 
d025ffd
2.5.0
d025ffd