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

Unified Diff: core/fxge/ge/fx_ge_text.cpp

Issue 1875673004: Fix integer issues leading to out of bounds access in fx_ge_text.cpp. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: whitespace nit Created 4 years, 8 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/fxge/ge/fx_ge_text.cpp
diff --git a/core/fxge/ge/fx_ge_text.cpp b/core/fxge/ge/fx_ge_text.cpp
index 44ab9f7ab51899fdff23cf38138e05f2bffb06e5..470c590c00f41283a884250608a3054d9d733f34 100644
--- a/core/fxge/ge/fx_ge_text.cpp
+++ b/core/fxge/ge/fx_ge_text.cpp
@@ -4,6 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#include <limits>
+
#include "core/fxcodec/include/fx_codec.h"
#include "core/fxge/ge/fx_text_int.h"
#include "core/fxge/include/fx_freetype.h"
@@ -1568,9 +1570,12 @@ CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(CFX_Font* pFont,
}
if (skew) {
// skew is nonpositive so -skew is used as the index.
- skew = -skew <= static_cast<int>(ANGLESKEW_ARRAY_SIZE)
- ? -58
- : -g_AngleSkew[-skew];
+ if (skew < 0 && skew != std::numeric_limits<int>::min() &&
+ static_cast<size_t>(-skew) < ANGLESKEW_ARRAY_SIZE) {
Wei Li 2016/04/11 16:40:37 /skew < 0/skew <= 0/ Also, casting to size_t make
Oliver Chang 2016/04/11 16:51:42 Done.
+ skew = -g_AngleSkew[-skew];
+ } else {
+ skew = -58;
+ }
if (pFont->IsVertical())
ft_matrix.yx += ft_matrix.yy * skew / 100;
else
@@ -1834,9 +1839,12 @@ CFX_PathData* CFX_Font::LoadGlyphPath(uint32_t glyph_index, int dest_width) {
if (m_pSubstFont->m_ItalicAngle) {
int skew = m_pSubstFont->m_ItalicAngle;
// skew is nonpositive so -skew is used as the index.
- skew = -skew <= static_cast<int>(ANGLESKEW_ARRAY_SIZE)
- ? -58
- : -g_AngleSkew[-skew];
+ if (skew < 0 && skew != std::numeric_limits<int>::min() &&
Wei Li 2016/04/11 17:00:47 skew <= 0 here too. Since you are here, can you p
Oliver Chang 2016/04/11 17:06:47 Already made this <= 0 too. Added the comment
+ static_cast<size_t>(-skew) < ANGLESKEW_ARRAY_SIZE) {
+ skew = -g_AngleSkew[-skew];
+ } else {
+ skew = -58;
+ }
if (m_bVertical)
ft_matrix.yx += ft_matrix.yy * skew / 100;
else
« 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