[Libreoffice-commits] core.git: sfx2/source
Takeshi Abe
tabe at fixedpoint.jp
Tue Mar 22 13:42:35 UTC 2016
sfx2/source/doc/docinsert.cxx | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
New commits:
commit e3428225160923ecbc36e44a94389d8f44ab225d
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date: Mon Mar 21 08:16:42 2016 +0900
sfx2: Fix memleak
i.e. free pMedium when CheckPasswd_Impl() returns ERRCODE_ABORT.
Change-Id: I452074e5189afe64016226c1a193a68f40e9c43d
Reviewed-on: https://gerrit.libreoffice.org/23387
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Michael Stahl <mstahl at redhat.com>
diff --git a/sfx2/source/doc/docinsert.cxx b/sfx2/source/doc/docinsert.cxx
index 56a84ee..b4b3d74 100644
--- a/sfx2/source/doc/docinsert.cxx
+++ b/sfx2/source/doc/docinsert.cxx
@@ -39,6 +39,7 @@
#include <svl/eitem.hxx>
#include <svl/intitem.hxx>
#include <svl/stritem.hxx>
+#include <memory>
using namespace ::com::sun::star;
using namespace ::com::sun::star::lang;
@@ -80,14 +81,14 @@ void DocumentInserter::StartExecuteModal( const Link<sfx2::FileDialogHelper*,voi
SfxMedium* DocumentInserter::CreateMedium()
{
- SfxMedium* pMedium = nullptr;
+ std::unique_ptr<SfxMedium> pMedium;
if (!m_nError && m_pItemSet && !m_pURLList.empty())
{
DBG_ASSERT( m_pURLList.size() == 1, "DocumentInserter::CreateMedium(): invalid URL list count" );
OUString sURL(m_pURLList[0]);
- pMedium = new SfxMedium(
+ pMedium.reset(new SfxMedium(
sURL, SFX_STREAM_READONLY,
- SfxGetpApp()->GetFilterMatcher().GetFilter4FilterName( m_sFilter ), m_pItemSet );
+ SfxGetpApp()->GetFilterMatcher().GetFilter4FilterName( m_sFilter ), m_pItemSet ));
pMedium->UseInteractionHandler( true );
SfxFilterMatcher* pMatcher = nullptr;
if ( !m_sDocFactory.isEmpty() )
@@ -100,15 +101,15 @@ SfxMedium* DocumentInserter::CreateMedium()
if ( nError == ERRCODE_NONE && pFilter )
pMedium->SetFilter( pFilter );
else
- DELETEZ( pMedium );
+ pMedium.reset();
- if ( pMedium && CheckPasswd_Impl( nullptr, SfxGetpApp()->GetPool(), pMedium ) == ERRCODE_ABORT )
- pMedium = nullptr;
+ if ( pMedium && CheckPasswd_Impl( nullptr, SfxGetpApp()->GetPool(), pMedium.get() ) == ERRCODE_ABORT )
+ pMedium.reset();
DELETEZ( pMatcher );
}
- return pMedium;
+ return pMedium.release();
}
SfxMediumList* DocumentInserter::CreateMediumList()
More information about the Libreoffice-commits
mailing list