Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(446)

Unified Diff: src/effects/SkDashPathEffect.cpp

Issue 2165013002: limit the number of points in SkDashPathEffect::asPoints (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkDashPathEffect.cpp
diff --git a/src/effects/SkDashPathEffect.cpp b/src/effects/SkDashPathEffect.cpp
index 90af32ec5b0fb6686699271f2c888704207a65d4..c5bf40dc814f7512e196298a486a00b6104a9cdd 100644
--- a/src/effects/SkDashPathEffect.cpp
+++ b/src/effects/SkDashPathEffect.cpp
@@ -248,7 +248,15 @@ 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
reed1 2016/07/20 18:06:15 Alternative: we could just return false if the val
+ // otherwise cause the results->fPoints allocation below to OOM.
+ // Cap it to a sane value.
+ static const SkScalar kMaxPoints = 1000000;
+ SkScalar numIntervals = len2 / fIntervalLength;
+ if (!SkScalarIsFinite(numIntervals) || numIntervals > kMaxPoints) {
+ return false;
+ }
+ int numMidPoints = SkScalarFloorToInt(numIntervals);
results->fNumPoints += numMidPoints;
len2 -= numMidPoints * fIntervalLength;
bool partialLast = false;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698