diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-12-18 14:17:11 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-12-18 15:30:16 +0100 |
commit | fb19a399fef73c05bbe570cb32d43ccf28d1b9c6 (patch) | |
tree | 0b8d52e9bd81d04df835a9c7633fb159f75f1bb4 /sfx2 | |
parent | 6f8186138d560d1949f89f4a525c0bd911af203e (diff) |
use unique_ptr in SfxMediumList
fixing leak in SwGlobalTree::DialogClosedHdl
Change-Id: I4a8e883bfe62181d4e332b3a0bbb85bbb332f711
Reviewed-on: https://gerrit.libreoffice.org/65333
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/doc/docinsert.cxx | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/sfx2/source/doc/docinsert.cxx b/sfx2/source/doc/docinsert.cxx index d919f317123b..7b64851e0071 100644 --- a/sfx2/source/doc/docinsert.cxx +++ b/sfx2/source/doc/docinsert.cxx @@ -136,16 +136,16 @@ std::unique_ptr<SfxMedium> DocumentInserter::CreateMedium(char const*const pFall return pMedium; } -SfxMediumList* DocumentInserter::CreateMediumList() +SfxMediumList DocumentInserter::CreateMediumList() { - SfxMediumList* pMediumList = new SfxMediumList; + SfxMediumList aMediumList; if (!m_nError && m_pItemSet && !m_pURLList.empty()) { for (auto const& url : m_pURLList) { - SfxMedium* pMedium = new SfxMedium( + std::unique_ptr<SfxMedium> pMedium(new SfxMedium( url, SFX_STREAM_READONLY, - SfxGetpApp()->GetFilterMatcher().GetFilter4FilterName( m_sFilter ), std::unique_ptr<SfxItemSet>(m_pItemSet) ); + SfxGetpApp()->GetFilterMatcher().GetFilter4FilterName( m_sFilter ), std::unique_ptr<SfxItemSet>(m_pItemSet) )); pMedium->UseInteractionHandler( true ); @@ -155,16 +155,14 @@ SfxMediumList* DocumentInserter::CreateMediumList() if ( nError == ERRCODE_NONE && pFilter ) pMedium->SetFilter( pFilter ); else - DELETEZ( pMedium ); + pMedium.reset(); - if( pMedium && CheckPasswd_Impl( nullptr, pMedium ) != ERRCODE_ABORT ) - pMediumList->push_back( pMedium ); - else - delete pMedium; + if( pMedium && CheckPasswd_Impl( nullptr, pMedium.get() ) != ERRCODE_ABORT ) + aMediumList.push_back( std::move(pMedium) ); } } - return pMediumList; + return aMediumList; } static void impl_FillURLList( sfx2::FileDialogHelper const * _pFileDlg, std::vector<OUString>& _rpURLList ) |