diff options
author | weili <weili@chromium.org> | 2016-09-01 17:42:11 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-01 17:42:11 -0700 |
commit | 7e4e63b04f87c690b017c43ebbb3218eb30c459a (patch) | |
tree | 8c341dd8f815902f77c7b6a3a569b8d24944b2c2 /xfa/fgas/font/fgas_gefont.cpp | |
parent | 6708106e6a3d54f3370c871ebf6643d1ecf58999 (diff) | |
download | pdfium-7e4e63b04f87c690b017c43ebbb3218eb30c459a.tar.xz |
Revert of Fix leaked internal font (patchset #2 id:60001 of https://codereview.chromium.org/2297303004/ )
Reason for revert:
asan bot doesn't like it, will investigate
Original issue's description:
> Fix leaked internal font
>
> 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 boolean parameter and pass it along
> during the creation of the font.
>
> BUG=pdfium:242
>
> Committed: https://pdfium.googlesource.com/pdfium/+/6708106e6a3d54f3370c871ebf6643d1ecf58999
TBR=thestig@chromium.org,dsinclair@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=pdfium:242
Review-Url: https://codereview.chromium.org/2302213002
Diffstat (limited to 'xfa/fgas/font/fgas_gefont.cpp')
-rw-r--r-- | xfa/fgas/font/fgas_gefont.cpp | 41 |
1 files changed, 10 insertions, 31 deletions
diff --git a/xfa/fgas/font/fgas_gefont.cpp b/xfa/fgas/font/fgas_gefont.cpp index 33d17489fa..1507fa4840 100644 --- a/xfa/fgas/font/fgas_gefont.cpp +++ b/xfa/fgas/font/fgas_gefont.cpp @@ -34,21 +34,10 @@ CFGAS_GEFont* CFGAS_GEFont::LoadFont(const FX_WCHAR* pszFontFamily, } // static -CFGAS_GEFont* CFGAS_GEFont::LoadFont(CFX_Font* pExternalFont, +CFGAS_GEFont* CFGAS_GEFont::LoadFont(CFX_Font* pExtFont, IFGAS_FontMgr* pFontMgr) { CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); - if (!pFont->LoadFontInternal(pExternalFont)) { - pFont->Release(); - return nullptr; - } - return pFont; -} - -// static -CFGAS_GEFont* CFGAS_GEFont::LoadFont(std::unique_ptr<CFX_Font> pInternalFont, - IFGAS_FontMgr* pFontMgr) { - CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); - if (!pFont->LoadFontInternal(std::move(pInternalFont))) { + if (!pFont->LoadFontInternal(pExtFont)) { pFont->Release(); return nullptr; } @@ -90,7 +79,7 @@ CFGAS_GEFont::CFGAS_GEFont(IFGAS_FontMgr* pFontMgr) m_pFont(nullptr), m_pFontMgr(pFontMgr), m_iRefCount(1), - m_bExternalFont(false), + m_bExtFont(FALSE), m_pProvider(nullptr) { } @@ -103,7 +92,7 @@ CFGAS_GEFont::CFGAS_GEFont(const CFGAS_GEFont& src, uint32_t dwFontStyles) m_pFont(nullptr), m_pFontMgr(src.m_pFontMgr), m_iRefCount(1), - m_bExternalFont(false), + m_bExtFont(FALSE), m_pProvider(nullptr) { ASSERT(src.m_pFont); m_pFont = new CFX_Font; @@ -128,7 +117,7 @@ CFGAS_GEFont::~CFGAS_GEFont() { m_SubstFonts.RemoveAll(); m_FontMapper.clear(); - if (!m_bExternalFont) + if (!m_bExtFont) delete m_pFont; } @@ -220,22 +209,12 @@ FX_BOOL CFGAS_GEFont::LoadFontInternal(IFX_Stream* pFontStream, } #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ -FX_BOOL CFGAS_GEFont::LoadFontInternal(CFX_Font* pExternalFont) { - if (m_pFont || !pExternalFont) - return FALSE; - - m_pFont = pExternalFont; - m_bExternalFont = true; - return InitFont(); -} - -FX_BOOL CFGAS_GEFont::LoadFontInternal( - std::unique_ptr<CFX_Font> pInternalFont) { - if (m_pFont || !pInternalFont) +FX_BOOL CFGAS_GEFont::LoadFontInternal(CFX_Font* pExtFont) { + if (m_pFont || !pExtFont) { return FALSE; - - m_pFont = pInternalFont.release(); - m_bExternalFont = false; + } + m_pFont = pExtFont; + m_bExtFont = TRUE; return InitFont(); } |