[Libreoffice-commits] core.git: svx/source

Takeshi Abe tabe at fixedpoint.jp
Sun Sep 3 05:54:15 UTC 2017


 svx/source/xml/xmlxtexp.cxx |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

New commits:
commit 77dbcb5620c1d233d09f6374927ef0c149fc8210
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Sun Sep 3 06:51:34 2017 +0900

    svx: Fix memleak at early returns from SvxXMLXTableExportComponent::save
    
    Change-Id: Ic6da38a47f2c2f2e350a15bad2b2731ed12409a9
    Reviewed-on: https://gerrit.libreoffice.org/41853
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>

diff --git a/svx/source/xml/xmlxtexp.cxx b/svx/source/xml/xmlxtexp.cxx
index 2cb4fc05232f..4bb2e7484709 100644
--- a/svx/source/xml/xmlxtexp.cxx
+++ b/svx/source/xml/xmlxtexp.cxx
@@ -196,7 +196,7 @@ bool SvxXMLXTableExportComponent::save(
         OUString *pOptName )
 {
     bool bRet = false;
-    SfxMedium* pMedium = nullptr;
+    std::unique_ptr<SfxMedium> pMedium;
     SvXMLGraphicHelper* pGraphicHelper = nullptr;
     sal_Int32 eCreate = embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE;
 
@@ -227,7 +227,7 @@ bool SvxXMLXTableExportComponent::save(
                 xSubStorage = ::comphelper::OStorageHelper::GetStorageFromURL( rURL, eCreate );
             else
             {
-                pMedium = new SfxMedium( rURL, StreamMode::WRITE | StreamMode::TRUNC );
+                pMedium.reset(new SfxMedium( rURL, StreamMode::WRITE | StreamMode::TRUNC ));
 
                 SvStream* pStream = pMedium->GetOutStream();
                 if( !pStream )
@@ -305,10 +305,7 @@ bool SvxXMLXTableExportComponent::save(
     }
 
     if( pMedium )
-    {
         pMedium->Commit();
-        delete pMedium;
-    }
 
     return bRet;
 }


More information about the Libreoffice-commits mailing list