summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-06-26 21:09:48 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-26 21:09:48 +0000
commitdc006f9e436339adccc6b5c5bab09b77f518be04 (patch)
treea5fa6e38101eb07c4f98d9eea9bf0b5cf97babb9 /core/fpdfapi
parent4bd3a815393b3a6b2d9840fdd1de121deceb7b12 (diff)
downloadpdfium-dc006f9e436339adccc6b5c5bab09b77f518be04.tar.xz
Use UnownedPtr<> in CPDF_Font
Change-Id: I5dc72c48ffd50836dd8c6a21e23568bc8703ee5a Reviewed-on: https://pdfium-review.googlesource.com/36132 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/font/cfx_stockfontarray.cpp6
-rw-r--r--core/fpdfapi/font/cpdf_font.h6
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;