From 9a0736803ae6749ec508e1c3ff5f04a483bbcb56 Mon Sep 17 00:00:00 2001 From: weili Date: Thu, 8 Sep 2016 15:21:23 -0700 Subject: Reland of Fix leaked internal font Reland of Fix leaked internal font (patchset #2 id:60001 of https://codereview.chromium.org/2297303004/ ) In CFGAS_FontMgrImp::LoadFont(), a new internal font is created which is never released. It needs to be correctly marked as internal font to be released. Fix this by adding a new method to take the ownership of the font and mark it as internal font properly. The previous revert was caused by memory management errors which were fixed at https://codereview.chromium.org/2322043002/ BUG=pdfium:242 Review-Url: https://codereview.chromium.org/2320213002 --- xfa/fgas/font/fgas_stdfontmgr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'xfa/fgas/font/fgas_stdfontmgr.cpp') diff --git a/xfa/fgas/font/fgas_stdfontmgr.cpp b/xfa/fgas/font/fgas_stdfontmgr.cpp index a0e7e39a40..96081f5799 100644 --- a/xfa/fgas/font/fgas_stdfontmgr.cpp +++ b/xfa/fgas/font/fgas_stdfontmgr.cpp @@ -847,13 +847,13 @@ CFGAS_GEFont* CFGAS_FontMgrImp::LoadFont(const CFX_WideString& wsFaceName, if (!pFontStream) return nullptr; - CFX_Font* pInternalFont = new CFX_Font(); + std::unique_ptr pInternalFont(new CFX_Font()); if (!pInternalFont->LoadFile(pFontStream, iFaceIndex)) { pFontStream->Release(); return nullptr; } - CFGAS_GEFont* pFont = CFGAS_GEFont::LoadFont(pInternalFont, this); + CFGAS_GEFont* pFont = CFGAS_GEFont::LoadFont(std::move(pInternalFont), this); if (!pFont) { pFontStream->Release(); return nullptr; -- cgit v1.2.3