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

Unified Diff: ui/gfx/geometry/rect.cc

Issue 2268423003: Adjust gfx::Rect's width and height to avoid integer overflow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment. Created 4 years, 3 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 | « ui/gfx/geometry/rect.h ('k') | ui/gfx/geometry/rect_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/geometry/rect.cc
diff --git a/ui/gfx/geometry/rect.cc b/ui/gfx/geometry/rect.cc
index e7a3aa2aac93f14eb96c4832a130f4bbeafa9253..2a78d0b5c6e3696adeee8d5ffffa32b034e819f9 100644
--- a/ui/gfx/geometry/rect.cc
+++ b/ui/gfx/geometry/rect.cc
@@ -71,10 +71,16 @@ void Rect::Inset(int left, int top, int right, int bottom) {
void Rect::Offset(int horizontal, int vertical) {
origin_ += Vector2d(horizontal, vertical);
+ // Ensure that width and height remain valid.
+ set_width(width());
+ set_height(height());
}
void Rect::operator+=(const Vector2d& offset) {
origin_ += offset;
+ // Ensure that width and height remain valid.
+ set_width(width());
+ set_height(height());
}
void Rect::operator-=(const Vector2d& offset) {
« no previous file with comments | « ui/gfx/geometry/rect.h ('k') | ui/gfx/geometry/rect_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698