diff options
Diffstat (limited to 'core/fpdfapi')
-rw-r--r-- | core/fpdfapi/font/cfx_stockfontarray.cpp | 6 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_font.h | 6 |
2 files changed, 7 insertions, 5 deletions
diff --git a/core/fpdfapi/font/cfx_stockfontarray.cpp b/core/fpdfapi/font/cfx_stockfontarray.cpp index 0808471c82..3b61e11f36 100644 --- a/core/fpdfapi/font/cfx_stockfontarray.cpp +++ b/core/fpdfapi/font/cfx_stockfontarray.cpp @@ -15,8 +15,10 @@ CFX_StockFontArray::CFX_StockFontArray() {} CFX_StockFontArray::~CFX_StockFontArray() { for (size_t i = 0; i < FX_ArraySize(m_StockFonts); ++i) { - if (m_StockFonts[i]) - delete m_StockFonts[i]->GetFontDict(); + if (m_StockFonts[i]) { + std::unique_ptr<CPDF_Dictionary> destroy(m_StockFonts[i]->GetFontDict()); + m_StockFonts[i]->ClearFontDict(); + } } } diff --git a/core/fpdfapi/font/cpdf_font.h b/core/fpdfapi/font/cpdf_font.h index 4b099ae0d0..9580d1c36b 100644 --- a/core/fpdfapi/font/cpdf_font.h +++ b/core/fpdfapi/font/cpdf_font.h @@ -66,8 +66,8 @@ class CPDF_Font { ByteString GetBaseFont() const { return m_BaseFont; } CFX_SubstFont* GetSubstFont() const { return m_Font.GetSubstFont(); } bool IsEmbedded() const { return IsType3Font() || m_pFontFile != nullptr; } - const CPDF_Dictionary* GetFontDict() const { return m_pFontDict; } - CPDF_Dictionary* GetFontDict() { return m_pFontDict; } + CPDF_Dictionary* GetFontDict() const { return m_pFontDict.Get(); } + void ClearFontDict() { m_pFontDict = nullptr; } bool IsStandardFont() const; FXFT_Face GetFace() const { return m_Font.GetFace(); } void AppendChar(ByteString* str, uint32_t charcode) const; @@ -113,7 +113,7 @@ class CPDF_Font { std::vector<std::unique_ptr<CFX_Font>> m_FontFallbacks; ByteString m_BaseFont; RetainPtr<CPDF_StreamAcc> m_pFontFile; - CPDF_Dictionary* m_pFontDict; + UnownedPtr<CPDF_Dictionary> m_pFontDict; mutable std::unique_ptr<CPDF_ToUnicodeMap> m_pToUnicodeMap; mutable bool m_bToUnicodeLoaded; int m_Flags; |