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

Unified Diff: src/core/SkMipMap.cpp

Issue 729373004: Watch out for SkFixed overflow in SkMipMap.cpp. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nan Created 6 years, 1 month 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 | « include/core/SkTypes.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkMipMap.cpp
diff --git a/src/core/SkMipMap.cpp b/src/core/SkMipMap.cpp
index fdfb660ccc66a2aa06deca8a052350b30ead8aaa..83164b15267e0169754ddfd5d7848093ba078e6b 100644
--- a/src/core/SkMipMap.cpp
+++ b/src/core/SkMipMap.cpp
@@ -228,7 +228,11 @@ SkMipMap* SkMipMap::Build(const SkBitmap& src, SkDiscardableFactoryProc fact) {
//static int gCounter;
static SkFixed compute_level(SkScalar scale) {
- SkFixed s = SkAbs32(SkScalarToFixed(SkScalarInvert(scale)));
+ SkScalar inv = SkScalarAbs(SkScalarInvert(scale));
+ if (inv > 32767) { // Watch out for SkFixed overflow.
+ inv = 32767;
+ }
+ SkFixed s = SkScalarToFixed(inv);
if (s < SK_Fixed1) {
return 0;
« no previous file with comments | « include/core/SkTypes.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698