| Index: src/effects/SkDashPathEffect.cpp
|
| diff --git a/src/effects/SkDashPathEffect.cpp b/src/effects/SkDashPathEffect.cpp
|
| index 90af32ec5b0fb6686699271f2c888704207a65d4..30d7667d178ecaa4220657c5fc01eda285a2aab3 100644
|
| --- a/src/effects/SkDashPathEffect.cpp
|
| +++ b/src/effects/SkDashPathEffect.cpp
|
| @@ -248,7 +248,14 @@ bool SkDashPathEffect::asPoints(PointData* results,
|
| len2 -= clampedInitialDashLength; // skip initial partial empty
|
| }
|
| }
|
| - int numMidPoints = SkScalarFloorToInt(len2 / fIntervalLength);
|
| + // Too many midpoints can cause results->fNumPoints to overflow or
|
| + // otherwise cause the results->fPoints allocation below to OOM.
|
| + // Cap it to a sane value.
|
| + SkScalar numIntervals = len2 / fIntervalLength;
|
| + if (!SkScalarIsFinite(numIntervals) || numIntervals > SkDashPath::kMaxDashCount) {
|
| + return false;
|
| + }
|
| + int numMidPoints = SkScalarFloorToInt(numIntervals);
|
| results->fNumPoints += numMidPoints;
|
| len2 -= numMidPoints * fIntervalLength;
|
| bool partialLast = false;
|
|
|