From 206dbe8a21b614bbf09b9d2b488ff453e41fdfd9 Mon Sep 17 00:00:00 2001 From: Jim Van Verth Date: Mon, 23 Jul 2018 11:48:31 -0400 Subject: Restrict radial step count Bug: skia:8164 Change-Id: I180f3c097b76f89ce57b780eaf28fb3db2759831 Reviewed-on: https://skia-review.googlesource.com/142895 Commit-Queue: Jim Van Verth Commit-Queue: Ben Wagner Auto-Submit: Jim Van Verth Reviewed-by: Ben Wagner --- src/utils/SkPolyUtils.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/utils/SkPolyUtils.cpp b/src/utils/SkPolyUtils.cpp index 0d1b71c76b..8a4bf49000 100644 --- a/src/utils/SkPolyUtils.cpp +++ b/src/utils/SkPolyUtils.cpp @@ -486,7 +486,13 @@ bool SkComputeRadialSteps(const SkVector& v1, const SkVector& v2, SkScalar r, } SkScalar theta = SkScalarATan2(rSin, rCos); - int steps = SkScalarRoundToInt(SkScalarAbs(r*theta*kRecipPixelsPerArcSegment)); + SkScalar floatSteps = SkScalarAbs(r*theta*kRecipPixelsPerArcSegment); + // limit the number of steps to at most max uint16_t (that's all we can index) + // knock one value off the top to account for rounding + if (floatSteps >= (1 << 16)-1) { + return false; + } + int steps = SkScalarRoundToInt(floatSteps); SkScalar dTheta = steps > 0 ? theta / steps : 0; *rotSin = SkScalarSinCos(dTheta, rotCos); -- cgit v1.2.3