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

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

Issue 2293633002: Guard against overflow when calculating font weight. (Closed)
Patch Set: review feedback Created 4 years, 4 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
Index: core/fpdfapi/fpdf_font/cpdf_cidfont.cpp
diff --git a/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp b/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp
index 491bd6d0c7895c70e4a67efb93cc1f8681139022..d3b57859914270e16f065e59c0f766103427ce64 100644
--- a/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp
+++ b/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp
@@ -18,6 +18,7 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h"
#include "core/fpdfapi/include/cpdf_modulemgr.h"
+#include "third_party/base/numerics/safe_math.h"
namespace {
@@ -768,7 +769,10 @@ FX_BOOL CPDF_CIDFont::IsUnicodeCompatible() const {
}
void CPDF_CIDFont::LoadSubstFont() {
- m_Font.LoadSubst(m_BaseFont, !m_bType1, m_Flags, m_StemV * 5, m_ItalicAngle,
+ pdfium::base::CheckedNumeric<int> safeStemV(m_StemV);
+ safeStemV *= 5;
+ m_Font.LoadSubst(m_BaseFont, !m_bType1, m_Flags,
+ safeStemV.ValueOrDefault(140), m_ItalicAngle,
Wei Li 2016/08/29 23:05:48 Maybe it is worth defining a constant for the defa
dsinclair 2016/08/30 14:26:39 Went with FXFONT_FW_NORMAL.
g_CharsetCPs[m_Charset], IsVertWriting());
}
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_font/cpdf_simplefont.cpp » ('j') | core/fpdfapi/fpdf_font/cpdf_simplefont.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698