Chromium Code Reviews| Index: core/fpdfapi/fpdf_font/fpdf_font.cpp |
| diff --git a/core/fpdfapi/fpdf_font/fpdf_font.cpp b/core/fpdfapi/fpdf_font/fpdf_font.cpp |
| index cff5223a008ba749de4f3a1a07ec768c7e2822d3..825cd61b521ac12526ab8e3517028a6b472f62e9 100644 |
| --- a/core/fpdfapi/fpdf_font/fpdf_font.cpp |
| +++ b/core/fpdfapi/fpdf_font/fpdf_font.cpp |
| @@ -18,6 +18,7 @@ |
| #include "core/fpdfapi/fpdf_parser/cpdf_simple_parser.h" |
| #include "core/fpdfapi/fpdf_parser/cpdf_stream_acc.h" |
| #include "core/fxcrt/fx_ext.h" |
| +#include "core/fxcrt/fx_safe_types.h" |
| #include "core/fxge/fx_freetype.h" |
| #include "third_party/base/numerics/safe_conversions.h" |
| #include "third_party/base/stl_util.h" |
| @@ -224,7 +225,10 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { |
| if (len == 1) { |
| m_Map[srccode] = destcode.GetAt(0); |
| } else { |
| - m_Map[srccode] = m_MultiCharBuf.GetLength() * 0x10000 + 0xffff; |
| + FX_SAFE_UINT32 uni = m_MultiCharBuf.GetLength(); |
| + uni *= 0x10000; |
| + uni += 0xffff; |
| + m_Map[srccode] = uni.ValueOrDie(); |
| m_MultiCharBuf.AppendChar(destcode.GetLength()); |
|
Tom Sepez
2016/10/04 17:41:21
Drive-by: do we prefer skipping/defaulting the val
npm
2016/10/04 19:24:17
I would say we prefer not crashing whenever possib
dsinclair
2016/10/04 19:27:59
Do we know what a sensible default should be? If t
|
| m_MultiCharBuf << destcode; |
| } |
| @@ -255,7 +259,10 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { |
| if (len == 1) { |
| m_Map[code] = destcode.GetAt(0); |
| } else { |
| - m_Map[code] = m_MultiCharBuf.GetLength() * 0x10000 + 0xffff; |
| + FX_SAFE_UINT32 uni = m_MultiCharBuf.GetLength(); |
| + uni *= 0x10000; |
| + uni += 0xffff; |
| + m_Map[code] = uni.ValueOrDie(); |
| m_MultiCharBuf.AppendChar(destcode.GetLength()); |
| m_MultiCharBuf << destcode; |
| } |
| @@ -278,7 +285,10 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { |
| } else { |
| retcode = StringDataAdd(destcode); |
| } |
| - m_Map[code] = m_MultiCharBuf.GetLength() * 0x10000 + 0xffff; |
| + FX_SAFE_UINT32 uni = m_MultiCharBuf.GetLength(); |
|
dsinclair
2016/10/04 17:15:31
Followup: These 6 lines are basically the same in
npm
2016/10/04 19:24:17
Sounds good
|
| + uni *= 0x10000; |
| + uni += 0xffff; |
| + m_Map[code] = uni.ValueOrDie(); |
| m_MultiCharBuf.AppendChar(retcode.GetLength()); |
| m_MultiCharBuf << retcode; |
| destcode = retcode; |