Fix overflow in CreateIntegralTable

Bug: oss-fuzz:55675
Change-Id: I0da6c709ad0a42e0f95dfa0f5733dd88876feb0d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/639076
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
diff --git a/src/core/SkGpuBlurUtils.cpp b/src/core/SkGpuBlurUtils.cpp
index 1813a10..dc84362 100644
--- a/src/core/SkGpuBlurUtils.cpp
+++ b/src/core/SkGpuBlurUtils.cpp
@@ -908,11 +908,16 @@
 // TODO: it seems like there should be some synergy with SkBlurMask::ComputeBlurProfile
 // TODO: maybe cache this on the cpu side?
 int CreateIntegralTable(float sixSigma, SkBitmap* table) {
+    // Avoid overflow, covers both multiplying by 2 and finding next power of 2:
+    // 2*((2^31-1)/4 + 1) = 2*(2^29-1) + 2 = 2^30 and SkNextPow2(2^30) = 2^30
+    if (sixSigma > SK_MaxS32/4 + 1) {
+        return 0;
+    }
     // The texture we're producing represents the integral of a normal distribution over a
     // six-sigma range centered at zero. We want enough resolution so that the linear
     // interpolation done in texture lookup doesn't introduce noticeable artifacts. We
     // conservatively choose to have 2 texels for each dst pixel.
-    int minWidth = 2 * sk_float_ceil2int(sixSigma);
+    int minWidth = 2*((int)sk_float_ceil(sixSigma));
     // Bin by powers of 2 with a minimum so we get good profile reuse.
     int width = std::max(SkNextPow2(minWidth), 32);