summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2017-06-21 17:01:02 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-06-21 21:14:05 +0000
commit4b95360b7611aa73f928de2dc47390f78573c6cc (patch)
tree909636e0efcf2ec88b820c91baf4270217f20756 /core
parenteca45e00c04fea5fa6be10a17f61cbcec6cba131 (diff)
downloadpdfium-4b95360b7611aa73f928de2dc47390f78573c6cc.tar.xz
Clamp instead of checked_cast in TT2PDF
Bug: chromium:727938 Change-Id: I85fe329c9d19c1dd1303279b0a9aade2fcc3211c Reviewed-on: https://pdfium-review.googlesource.com/6814 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/font/cpdf_font.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/core/fpdfapi/font/cpdf_font.cpp b/core/fpdfapi/font/cpdf_font.cpp
index bdd3464ed2..82f9be3361 100644
--- a/core/fpdfapi/font/cpdf_font.cpp
+++ b/core/fpdfapi/font/cpdf_font.cpp
@@ -6,6 +6,7 @@
#include "core/fpdfapi/font/cpdf_font.h"
+#include <limits>
#include <memory>
#include <utility>
#include <vector>
@@ -486,8 +487,11 @@ int CPDF_Font::TT2PDF(int m, FXFT_Face face) {
int upm = FXFT_Get_Face_UnitsPerEM(face);
if (upm == 0)
return m;
- return pdfium::base::checked_cast<int>(
- (static_cast<double>(m) * 1000 + upm / 2) / upm);
+
+ return static_cast<int>(
+ pdfium::clamp((m * 1000.0 + upm / 2) / upm,
+ static_cast<double>(std::numeric_limits<int>::min()),
+ static_cast<double>(std::numeric_limits<int>::max())));
}
// static