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

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

Issue 1371753004: ui/gfx: Make gfx::Size::GetArea use checked math. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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/size.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/geometry/size.cc
diff --git a/ui/gfx/geometry/size.cc b/ui/gfx/geometry/size.cc
index 86e1aeb9b174f90345880a02af21d694acb1ecc6..e58bb22fd8e535cdc914e12e715a58cac4e8f3d7 100644
--- a/ui/gfx/geometry/size.cc
+++ b/ui/gfx/geometry/size.cc
@@ -12,6 +12,7 @@
#include <ApplicationServices/ApplicationServices.h>
#endif
+#include "base/numerics/safe_math.h"
#include "base/strings/stringprintf.h"
#include "ui/gfx/geometry/size_conversions.h"
@@ -44,7 +45,9 @@ CGSize Size::ToCGSize() const {
#endif
int Size::GetArea() const {
- return width() * height();
+ base::CheckedNumeric<int> checked_area = width();
+ checked_area *= height();
+ return checked_area.ValueOrDie();
}
void Size::Enlarge(int grow_width, int grow_height) {
« no previous file with comments | « ui/gfx/geometry/size.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698