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

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: fix SpecialLineRec point count overflow 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 | src/utils/SkDashPath.cpp » ('j') | src/utils/SkDashPath.cpp » ('J')
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..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;
« no previous file with comments | « no previous file | src/utils/SkDashPath.cpp » ('j') | src/utils/SkDashPath.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698