Index: src/core/SkMipMap.cpp |
diff --git a/src/core/SkMipMap.cpp b/src/core/SkMipMap.cpp |
index ff62f4d59d53b154340d69a611621fec49edc1c7..4888b574e4a687c63e400374b99d4c973686535b 100644 |
--- a/src/core/SkMipMap.cpp |
+++ b/src/core/SkMipMap.cpp |
@@ -109,15 +109,21 @@ |
*dst->getAddr16(x >> 1, y >> 1) = (uint16_t)collaps4444(c >> 2); |
} |
+static bool isPos32Bits(const Sk64& value) { |
+ return !value.isNeg() && value.is32(); |
+} |
+ |
SkMipMap::Level* SkMipMap::AllocLevels(int levelCount, size_t pixelSize) { |
if (levelCount < 0) { |
return NULL; |
} |
- int64_t size = sk_64_mul(levelCount + 1, sizeof(Level)) + pixelSize; |
- if (!sk_64_isS32(size)) { |
- return NULL; |
- } |
- return (Level*)sk_malloc_throw(sk_64_asS32(size)); |
+ Sk64 size; |
+ size.setMul(levelCount + 1, sizeof(Level)); |
+ size.add(SkToS32(pixelSize)); |
+ if (!isPos32Bits(size)) { |
+ return NULL; |
+ } |
+ return (Level*)sk_malloc_throw(size.get32()); |
} |
SkMipMap* SkMipMap::Build(const SkBitmap& src) { |