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

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

Issue 2248473002: Fix a potential integer overflow in TT2PDF(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium@fontclean_smallrect
Patch Set: rebase 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 fefe9365437bde1846c77ddb5dfa8599ee7cd4f9..a14c43d4fa548ef7c9f4aa8ac1695b0e60710213 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) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698