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

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

Issue 2354783004: Fix overflow/underflow in gfx geometry once and for all (Closed)
Patch Set: Remove accessibility test changes Created 4 years, 2 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/size_unittest.cc ('k') | ui/gfx/geometry/vector2d_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/geometry/vector2d.cc
diff --git a/ui/gfx/geometry/vector2d.cc b/ui/gfx/geometry/vector2d.cc
index 43f25e933a0e9c088ee298a392a6d4103a9db260..aec4d28b9b0fec0f0cdebe65f9462ac68466f4f3 100644
--- a/ui/gfx/geometry/vector2d.cc
+++ b/ui/gfx/geometry/vector2d.cc
@@ -7,6 +7,7 @@
#include <cmath>
#include "base/strings/stringprintf.h"
+#include "ui/gfx/geometry/safe_integer_conversions.h"
namespace gfx {
@@ -15,13 +16,13 @@ bool Vector2d::IsZero() const {
}
void Vector2d::Add(const Vector2d& other) {
- x_ += other.x_;
- y_ += other.y_;
+ x_ = SafeAdd(other.x_, x_);
+ y_ = SafeAdd(other.y_, y_);
}
void Vector2d::Subtract(const Vector2d& other) {
- x_ -= other.x_;
- y_ -= other.y_;
+ x_ = SafeSubtract(x_, other.x_);
+ y_ = SafeSubtract(y_, other.y_);
}
int64_t Vector2d::LengthSquared() const {
« no previous file with comments | « ui/gfx/geometry/size_unittest.cc ('k') | ui/gfx/geometry/vector2d_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698