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

Unified Diff: third_party/WebKit/Source/platform/fonts/shaping/ShapeResult.cpp

Issue 2176053002: Avoid integer-overflow in hb_glyph_position_t.y_advance (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment Created 4 years, 5 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: third_party/WebKit/Source/platform/fonts/shaping/ShapeResult.cpp
diff --git a/third_party/WebKit/Source/platform/fonts/shaping/ShapeResult.cpp b/third_party/WebKit/Source/platform/fonts/shaping/ShapeResult.cpp
index e05e7b13da28da65a3873b572c727bd5b5916c04..9893ee4cc4098d0715a70881109f291b34dae37f 100644
--- a/third_party/WebKit/Source/platform/fonts/shaping/ShapeResult.cpp
+++ b/third_party/WebKit/Source/platform/fonts/shaping/ShapeResult.cpp
@@ -311,7 +311,12 @@ void ShapeResult::insertRun(std::unique_ptr<ShapeResult::RunInfo> runToInsert,
// One out of x_advance and y_advance is zero, depending on
// whether the buffer direction is horizontal or vertical.
- float advance = harfBuzzPositionToFloat(pos.x_advance - pos.y_advance);
+ // Convert to float and negate to avoid integer-overflow for ULONG_MAX.
+ float advance;
+ if (LIKELY(pos.x_advance))
+ advance = harfBuzzPositionToFloat(pos.x_advance);
+ else
+ advance = -harfBuzzPositionToFloat(pos.y_advance);
run->m_glyphData[i].characterIndex =
glyphInfos[startGlyph + i].cluster - startCluster;
« 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