Don't check null returns from CFX_FontMgr::GetBuiltinMapper().
The underlying member is created in the ctor and deleted
only in the dtor, so paths that check for nullness are not
reachable.
Change-Id: I952718e2dfff485c06628150aaa7d81756c93b49
Reviewed-on: https://pdfium-review.googlesource.com/c/48411
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxge/cfx_fontmgr.cpp b/core/fxge/cfx_fontmgr.cpp
index e781a70..f3d74c3 100644
--- a/core/fxge/cfx_fontmgr.cpp
+++ b/core/fxge/cfx_fontmgr.cpp
@@ -76,8 +76,7 @@
} // namespace
-CFX_FontMgr::CFX_FontMgr()
- : m_FTLibrary(nullptr), m_FTLibrarySupportsHinting(false) {
+CFX_FontMgr::CFX_FontMgr() {
m_pBuiltinMapper = pdfium::MakeUnique<CFX_FontMapper>(this);
}
diff --git a/core/fxge/cfx_fontmgr.h b/core/fxge/cfx_fontmgr.h
index 609d51b..fada47d 100644
--- a/core/fxge/cfx_fontmgr.h
+++ b/core/fxge/cfx_fontmgr.h
@@ -57,7 +57,10 @@
int CharsetCP,
CFX_SubstFont* pSubstFont);
Optional<pdfium::span<const uint8_t>> GetBuiltinFont(size_t index);
+
+ // Always present.
CFX_FontMapper* GetBuiltinMapper() const { return m_pBuiltinMapper.get(); }
+
FXFT_Library GetFTLibrary() const { return m_FTLibrary; }
bool FTLibrarySupportsHinting() const { return m_FTLibrarySupportsHinting; }
@@ -67,8 +70,8 @@
std::unique_ptr<CFX_FontMapper> m_pBuiltinMapper;
std::map<ByteString, std::unique_ptr<CTTFontDesc>> m_FaceMap;
- FXFT_Library m_FTLibrary;
- bool m_FTLibrarySupportsHinting;
+ FXFT_Library m_FTLibrary = nullptr;
+ bool m_FTLibrarySupportsHinting = false;
};
#endif // CORE_FXGE_CFX_FONTMGR_H_
diff --git a/fpdfsdk/cfx_systemhandler.cpp b/fpdfsdk/cfx_systemhandler.cpp
index 42d1970..b43e303 100644
--- a/fpdfsdk/cfx_systemhandler.cpp
+++ b/fpdfsdk/cfx_systemhandler.cpp
@@ -76,9 +76,6 @@
return false;
CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper();
- if (!pFontMapper)
- return false;
-
pFontMapper->LoadInstalledFonts();
for (const auto& font : pFontMapper->m_InstalledTTFonts) {
diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp
index 0a1d531..7540213 100644
--- a/xfa/fgas/font/cfgas_fontmgr.cpp
+++ b/xfa/fgas/font/cfgas_fontmgr.cpp
@@ -463,9 +463,6 @@
const ByteString& bsFaceName) {
CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr();
CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper();
- if (!pFontMapper)
- return nullptr;
-
SystemFontInfoIface* pSystemFontInfo = pFontMapper->GetSystemFontInfo();
if (!pSystemFontInfo)
return nullptr;
@@ -629,9 +626,6 @@
bool CFGAS_FontMgr::EnumFontsFromFontMapper() {
CFX_FontMapper* pFontMapper =
CFX_GEModule::Get()->GetFontMgr()->GetBuiltinMapper();
- if (!pFontMapper)
- return false;
-
pFontMapper->LoadInstalledFonts();
SystemFontInfoIface* pSystemFontInfo = pFontMapper->GetSystemFontInfo();
@@ -707,9 +701,6 @@
int32_t iFaceIndex) {
CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr();
CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper();
- if (!pFontMapper)
- return nullptr;
-
SystemFontInfoIface* pSystemFontInfo = pFontMapper->GetSystemFontInfo();
if (!pSystemFontInfo)
return nullptr;