Remove impossible code related to CPDF_Type3Font.
CPDF_Type3Font always has a valid document.
Change-Id: I66729e348fec95ffe16c2248c6d738b7e7dcbc99
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/54211
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/font/cpdf_font.h b/core/fpdfapi/font/cpdf_font.h
index 74271bd..7159eb9 100644
--- a/core/fpdfapi/font/cpdf_font.h
+++ b/core/fpdfapi/font/cpdf_font.h
@@ -82,9 +82,13 @@
virtual uint32_t GetCharWidthF(uint32_t charcode) = 0;
virtual FX_RECT GetCharBBox(uint32_t charcode) = 0;
+ // Can return nullptr for stock Type1 fonts. Always returns non-null for other
+ // font types.
CPDF_Document* GetDocument() const { return m_pDocument.Get(); }
+
CFX_Font* GetFont() { return &m_Font; }
const CFX_Font* GetFont() const { return &m_Font; }
+
CFX_Font* GetFontFallback(int position);
protected:
diff --git a/core/fpdfapi/font/cpdf_type3font.cpp b/core/fpdfapi/font/cpdf_type3font.cpp
index d7bd7d0..df9bec7 100644
--- a/core/fpdfapi/font/cpdf_type3font.cpp
+++ b/core/fpdfapi/font/cpdf_type3font.cpp
@@ -26,10 +26,11 @@
CPDF_Type3Font::CPDF_Type3Font(CPDF_Document* pDocument,
CPDF_Dictionary* pFontDict)
: CPDF_SimpleFont(pDocument, pFontDict) {
+ ASSERT(GetDocument());
memset(m_CharWidthL, 0, sizeof(m_CharWidthL));
}
-CPDF_Type3Font::~CPDF_Type3Font() {}
+CPDF_Type3Font::~CPDF_Type3Font() = default;
bool CPDF_Type3Font::IsType3Font() const {
return true;
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 5f742ef..24ecc85 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -81,9 +81,6 @@
void ReleaseCachedType3(CPDF_Type3Font* pFont) {
CPDF_Document* pDoc = pFont->GetDocument();
- if (!pDoc)
- return;
-
pDoc->GetRenderData()->MaybePurgeCachedType3(pFont);
pDoc->GetPageData()->ReleaseFont(pFont->GetFontDict());
}
@@ -1784,9 +1781,6 @@
RetainPtr<CPDF_Type3Cache> CPDF_RenderStatus::GetCachedType3(
CPDF_Type3Font* pFont) {
CPDF_Document* pDoc = pFont->GetDocument();
- if (!pDoc)
- return nullptr;
-
pDoc->GetPageData()->GetFont(pFont->GetFontDict());
return pDoc->GetRenderData()->GetCachedType3(pFont);
}