Switch to std::array<> in CPDF_FontGlobals.
Take advantage of hardened libc++ where available.
Avoid some icky initialization using memset() (which shouldn't
have been necessary once the elements were converted to span<>
with its default ctor).
Change-Id: I901d73cccb095b0159fac5c7f4ab2031eec9de28
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/109690
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/font/cpdf_fontglobals.cpp b/core/fpdfapi/font/cpdf_fontglobals.cpp
index 1aa19d6..aa5386d 100644
--- a/core/fpdfapi/font/cpdf_fontglobals.cpp
+++ b/core/fpdfapi/font/cpdf_fontglobals.cpp
@@ -50,10 +50,7 @@
return g_FontGlobals;
}
-CPDF_FontGlobals::CPDF_FontGlobals() {
- memset(m_EmbeddedCharsets, 0, sizeof(m_EmbeddedCharsets));
- memset(m_EmbeddedToUnicodes, 0, sizeof(m_EmbeddedToUnicodes));
-}
+CPDF_FontGlobals::CPDF_FontGlobals() = default;
CPDF_FontGlobals::~CPDF_FontGlobals() = default;
diff --git a/core/fpdfapi/font/cpdf_fontglobals.h b/core/fpdfapi/font/cpdf_fontglobals.h
index 6b2e3bc..73f95fc 100644
--- a/core/fpdfapi/font/cpdf_fontglobals.h
+++ b/core/fpdfapi/font/cpdf_fontglobals.h
@@ -7,6 +7,7 @@
#ifndef CORE_FPDFAPI_FONT_CPDF_FONTGLOBALS_H_
#define CORE_FPDFAPI_FONT_CPDF_FONTGLOBALS_H_
+#include <array>
#include <functional>
#include <map>
#include <memory>
@@ -63,9 +64,12 @@
void LoadEmbeddedKorea1CMaps();
std::map<ByteString, RetainPtr<const CPDF_CMap>> m_CMaps;
- std::unique_ptr<CPDF_CID2UnicodeMap> m_CID2UnicodeMaps[CIDSET_NUM_SETS];
- pdfium::span<const fxcmap::CMap> m_EmbeddedCharsets[CIDSET_NUM_SETS];
- pdfium::span<const uint16_t> m_EmbeddedToUnicodes[CIDSET_NUM_SETS];
+ std::array<std::unique_ptr<CPDF_CID2UnicodeMap>, CIDSET_NUM_SETS>
+ m_CID2UnicodeMaps;
+ std::array<pdfium::span<const fxcmap::CMap>, CIDSET_NUM_SETS>
+ m_EmbeddedCharsets;
+ std::array<pdfium::span<const uint16_t>, CIDSET_NUM_SETS>
+ m_EmbeddedToUnicodes;
std::map<UnownedPtr<CPDF_Document>,
std::unique_ptr<CFX_StockFontArray>,
std::less<>>