Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2107)

Unified Diff: core/fpdfapi/font/fpdf_font.cpp

Issue 2392103002: Avoid crashing on CPDF_ToUnicodeMap::Load by using ValueOrDefault() (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fpdfapi/font/font_int.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/font/fpdf_font.cpp
diff --git a/core/fpdfapi/font/fpdf_font.cpp b/core/fpdfapi/font/fpdf_font.cpp
index 1273ff5f6d617107d29a050c09969ff77bc987a4..056204ad7e29adecf5783f1d974797230a6931ee 100644
--- a/core/fpdfapi/font/fpdf_font.cpp
+++ b/core/fpdfapi/font/fpdf_font.cpp
@@ -199,6 +199,12 @@ CPDF_ToUnicodeMap::CPDF_ToUnicodeMap() : m_pBaseMap(nullptr) {}
CPDF_ToUnicodeMap::~CPDF_ToUnicodeMap() {}
+uint32_t CPDF_ToUnicodeMap::GetUnicode() {
+ FX_SAFE_UINT32 uni = m_MultiCharBuf.GetLength();
+ uni = uni * 0x10000 + 0xffff;
+ return uni.ValueOrDefault(0);
+}
+
void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) {
CIDSet cid_set = CIDSET_UNKNOWN;
CPDF_StreamAcc stream;
@@ -225,10 +231,7 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) {
if (len == 1) {
m_Map[srccode] = destcode.GetAt(0);
} else {
- FX_SAFE_UINT32 uni = m_MultiCharBuf.GetLength();
- uni *= 0x10000;
- uni += 0xffff;
- m_Map[srccode] = uni.ValueOrDie();
+ m_Map[srccode] = GetUnicode();
m_MultiCharBuf.AppendChar(destcode.GetLength());
m_MultiCharBuf << destcode;
}
@@ -259,10 +262,7 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) {
if (len == 1) {
m_Map[code] = destcode.GetAt(0);
} else {
- FX_SAFE_UINT32 uni = m_MultiCharBuf.GetLength();
- uni *= 0x10000;
- uni += 0xffff;
- m_Map[code] = uni.ValueOrDie();
+ m_Map[code] = GetUnicode();
m_MultiCharBuf.AppendChar(destcode.GetLength());
m_MultiCharBuf << destcode;
}
@@ -285,10 +285,7 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) {
} else {
retcode = StringDataAdd(destcode);
}
- FX_SAFE_UINT32 uni = m_MultiCharBuf.GetLength();
- uni *= 0x10000;
- uni += 0xffff;
- m_Map[code] = uni.ValueOrDie();
+ m_Map[code] = GetUnicode();
m_MultiCharBuf.AppendChar(retcode.GetLength());
m_MultiCharBuf << retcode;
destcode = retcode;
« no previous file with comments | « core/fpdfapi/font/font_int.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698