Kaydet (Commit) e3428225 authored tarafından Takeshi Abe's avatar Takeshi Abe Kaydeden (comit) Michael Stahl

sfx2: Fix memleak

i.e. free pMedium when CheckPasswd_Impl() returns ERRCODE_ABORT.

Change-Id: I452074e5189afe64016226c1a193a68f40e9c43d
Reviewed-on: https://gerrit.libreoffice.org/23387Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMichael Stahl <mstahl@redhat.com>
üst 998be281
......@@ -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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment