diff options
author | Tom Sepez <tsepez@chromium.org> | 2014-10-13 13:16:32 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2014-10-13 13:16:32 -0700 |
commit | 9dd088033537c071725b9a61fd5b519d65ea9f13 (patch) | |
tree | d1e5227cb907ec7b043b615b0118f18852b59740 /core | |
parent | 6cf012af4954807255ce7cdb5b92a20f74d34e6d (diff) | |
download | pdfium-9dd088033537c071725b9a61fd5b519d65ea9f13.tar.xz |
Fix off-by-one in sizing of m_EmbeddedToUnicodes.
BUG=421196
R=bo_xu@foxitsoftware.com
Review URL: https://codereview.chromium.org/656463006
Diffstat (limited to 'core')
-rw-r--r-- | core/include/fpdfapi/fpdf_resource.h | 2 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_font/font_int.h | 4 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp | 17 |
3 files changed, 11 insertions, 12 deletions
diff --git a/core/include/fpdfapi/fpdf_resource.h b/core/include/fpdfapi/fpdf_resource.h index 937024c94e..7bad01501a 100644 --- a/core/include/fpdfapi/fpdf_resource.h +++ b/core/include/fpdfapi/fpdf_resource.h @@ -480,6 +480,8 @@ protected: #define CIDSET_JAPAN1 3 #define CIDSET_KOREA1 4 #define CIDSET_UNICODE 5 +#define NUMBER_OF_CIDSETS 6 + class CPDF_CIDFont : public CPDF_Font { public: diff --git a/core/src/fpdfapi/fpdf_font/font_int.h b/core/src/fpdfapi/fpdf_font/font_int.h index b151d78b51..3ce9664ceb 100644 --- a/core/src/fpdfapi/fpdf_font/font_int.h +++ b/core/src/fpdfapi/fpdf_font/font_int.h @@ -39,11 +39,11 @@ public: struct { const struct FXCMAP_CMap* m_pMapList; int m_Count; - } m_EmbeddedCharsets[5]; + } m_EmbeddedCharsets[NUMBER_OF_CIDSETS]; struct { const FX_WORD* m_pMap; int m_Count; - } m_EmbeddedToUnicodes[5]; + } m_EmbeddedToUnicodes[NUMBER_OF_CIDSETS]; FX_LPBYTE m_pContrastRamps; }; struct _CMap_CodeRange { diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp index 2cee90c24a..e5dabc33da 100644 --- a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp +++ b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp @@ -76,18 +76,15 @@ CPDF_CMap* CPDF_CMapManager::LoadPredefinedCMap(const CFX_ByteString& name, FX_B pCMap->LoadPredefined(this, pname, bPromptCJK); return pCMap; } -const FX_LPCSTR g_CharsetNames[] = {NULL, "GB1", "CNS1", "Japan1", "Korea1", "UCS", NULL}; -const int g_CharsetCPs[] = {0, 936, 950, 932, 949, 1200, 0}; +static const FX_LPCSTR g_CharsetNames[NUMBER_OF_CIDSETS] = {NULL, "GB1", "CNS1", "Japan1", "Korea1", "UCS" }; +static const int g_CharsetCPs[NUMBER_OF_CIDSETS] = {0, 936, 950, 932, 949, 1200 }; int _CharsetFromOrdering(const CFX_ByteString& Ordering) { - int charset = 1; - while (g_CharsetNames[charset] && Ordering != CFX_ByteStringC(g_CharsetNames[charset])) { - charset ++; - } - if (g_CharsetNames[charset] == NULL) { - return CIDSET_UNKNOWN; - } - return charset; + for (int charset = 1; charset < NUMBER_OF_CIDSETS; charset++) { + if (Ordering == CFX_ByteStringC(g_CharsetNames[charset])) + return charset; + } + return CIDSET_UNKNOWN; } void CPDF_CMapManager::ReloadAll() { |