From c29fc707b24b9528e41a242cfa298275708ffc76 Mon Sep 17 00:00:00 2001 From: weili Date: Thu, 8 Sep 2016 11:47:29 -0700 Subject: Fix memory management errors for font loading and copying A few issues are fixed: --Change variable |m_bLogic| in CFX_Font to |m_bShallowCopy| to reflect its meaning better; --For a shallow copy of font, we must guarantee that the copied font will not be deleted until the shallow copy is deleted. So need to increase the src font's refcount when copying it; --The stream |m_pOwnedStream| needs to have matched new/delete These errors need to be fixed before we can properly delete all the fonts to address the leaks. BUG=pdfium:242 Review-Url: https://codereview.chromium.org/2322043002 --- xfa/fgas/font/fgas_gefont.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'xfa/fgas/font/fgas_gefont.h') diff --git a/xfa/fgas/font/fgas_gefont.h b/xfa/fgas/font/fgas_gefont.h index cdb19338a2..d139d445f4 100644 --- a/xfa/fgas/font/fgas_gefont.h +++ b/xfa/fgas/font/fgas_gefont.h @@ -65,7 +65,7 @@ class CFGAS_GEFont { protected: explicit CFGAS_GEFont(IFGAS_FontMgr* pFontMgr); - CFGAS_GEFont(const CFGAS_GEFont& src, uint32_t dwFontStyles); + CFGAS_GEFont(CFGAS_GEFont* src, uint32_t dwFontStyles); #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ FX_BOOL LoadFontInternal(const FX_WCHAR* pszFontFamily, @@ -94,6 +94,7 @@ class CFGAS_GEFont { uint32_t m_dwLogFontStyle; #endif CFX_Font* m_pFont; + CFGAS_GEFont* const m_pSrcFont; IFGAS_FontMgr* const m_pFontMgr; int32_t m_iRefCount; FX_BOOL m_bExtFont; -- cgit v1.2.3