From e805881d74392969746d34756b035850c67883e6 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 26 May 2017 10:27:48 +0100 Subject: coverity#1409895 Resource leak Change-Id: I1430ac41bf11bf3ae5c4cba3406a24148acd728e --- sw/source/uibase/dialog/watermarkdialog.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'sw/source/uibase/dialog') diff --git a/sw/source/uibase/dialog/watermarkdialog.cxx b/sw/source/uibase/dialog/watermarkdialog.cxx index 6b993d22caf1..29131215a72b 100644 --- a/sw/source/uibase/dialog/watermarkdialog.cxx +++ b/sw/source/uibase/dialog/watermarkdialog.cxx @@ -57,12 +57,16 @@ void SwWatermarkDialog::InitFields() SfxObjectShell* pDocSh = SfxObjectShell::Current(); const SfxPoolItem* pFontItem; const FontList* pFontList = nullptr; + std::unique_ptr xFontList; if ( pDocSh && ( ( pFontItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST ) ) != nullptr ) ) pFontList = static_cast( pFontItem )->GetFontList(); - if(!pFontList) - pFontList = new FontList(Application::GetDefaultDevice(), nullptr); + if (!pFontList) + { + xFontList.reset(new FontList(Application::GetDefaultDevice(), nullptr)); + pFontList = xFontList.get(); + } m_pFont->Fill( pFontList ); -- cgit