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; |