summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthestig <thestig@chromium.org>2016-08-15 11:40:17 -0700
committerCommit bot <commit-bot@chromium.org>2016-08-15 11:40:17 -0700
commit1099b29f5569004f8a83be93dbe0c31a3620a9e5 (patch)
tree48310d2d368f9a1453987fb59dbe1fa4dba37d38
parenta4941914bb4411dc4e9053cb344e0349db388007 (diff)
downloadpdfium-1099b29f5569004f8a83be93dbe0c31a3620a9e5.tar.xz
Fix a potential integer overflow in TT2PDF().chromium/2830
BUG=635438 Review-Url: https://codereview.chromium.org/2248473002
-rw-r--r--core/fpdfapi/fpdf_font/fpdf_font.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/core/fpdfapi/fpdf_font/fpdf_font.cpp b/core/fpdfapi/fpdf_font/fpdf_font.cpp
index fefe936543..a14c43d4fa 100644
--- a/core/fpdfapi/fpdf_font/fpdf_font.cpp
+++ b/core/fpdfapi/fpdf_font/fpdf_font.cpp
@@ -19,13 +19,15 @@
#include "core/fpdfapi/include/cpdf_modulemgr.h"
#include "core/fxcrt/include/fx_ext.h"
#include "core/fxge/include/fx_freetype.h"
+#include "third_party/base/numerics/safe_conversions.h"
#include "third_party/base/stl_util.h"
int TT2PDF(int m, FXFT_Face face) {
int upm = FXFT_Get_Face_UnitsPerEM(face);
if (upm == 0)
return m;
- return (m * 1000 + upm / 2) / upm;
+ return pdfium::base::checked_cast<int>(
+ (static_cast<double>(m) * 1000 + upm / 2) / upm);
}
bool FT_UseTTCharmap(FXFT_Face face, int platform_id, int encoding_id) {