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

Unified Diff: third_party/WebKit/Source/platform/LayoutUnit.h

Issue 2160983007: Avoid integer overflow in LayoutUnit's unary minus operator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Full UnaryMinus test case 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 | third_party/WebKit/Source/platform/LayoutUnitTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/LayoutUnit.h
diff --git a/third_party/WebKit/Source/platform/LayoutUnit.h b/third_party/WebKit/Source/platform/LayoutUnit.h
index 6611ca345d28169f96664a8977cf5e2fecc7521d..f8fd072314a06f65754c9f9277faa8a0d42a32cd 100644
--- a/third_party/WebKit/Source/platform/LayoutUnit.h
+++ b/third_party/WebKit/Source/platform/LayoutUnit.h
@@ -644,6 +644,10 @@ inline float operator-(const float a, const LayoutUnit& b)
inline LayoutUnit operator-(const LayoutUnit& a)
{
+ // -min() is saturated to max().
+ if (a == LayoutUnit::min())
+ return LayoutUnit::max();
+
LayoutUnit returnVal;
returnVal.setRawValue(-a.rawValue());
return returnVal;
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/LayoutUnitTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698