aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/SkDashPath.cpp
diff options
context:
space:
mode:
authorGravatar lsalzman <lsalzman@mozilla.com>2016-07-21 09:37:59 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-07-21 09:37:59 -0700
commitf41ae2f9738e32a43762b780e6d113b4b6157747 (patch)
tree678f86c9116c02df2afd1ae8a7eabc233573cbaa /src/utils/SkDashPath.cpp
parentf292a0c862f1c120cade1e8ac0f1882844eb343a (diff)
limit the number of points in SkDashPathEffect::asPoints
If the length of a line path is sufficiently long relative to the dash interval, it is possible to cause SkDashPathEffect::asPoints to produce so many points that it overflows the amount that can fit in an int type, or otherwise produce non-finite values, i.e. path from (0,0) to (0,9e15) with a dash interval of 1. This fixes that by capping the amount of points to a sane limit - in this case, 1mil, since that limit is also used in utils/SkDashPath.cpp and has precedent. Downstream Firefox bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=1287515 BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2165013002 Review-Url: https://codereview.chromium.org/2165013002
Diffstat (limited to 'src/utils/SkDashPath.cpp')
-rw-r--r--src/utils/SkDashPath.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/utils/SkDashPath.cpp b/src/utils/SkDashPath.cpp
index 8317d20f37..e06c2d2da3 100644
--- a/src/utils/SkDashPath.cpp
+++ b/src/utils/SkDashPath.cpp
@@ -176,6 +176,7 @@ public:
SkScalar ptCount = SkScalarMulDiv(pathLength,
SkIntToScalar(intervalCount),
intervalLength);
+ ptCount = SkTMin(ptCount, SkDashPath::kMaxDashCount);
int n = SkScalarCeilToInt(ptCount) << 2;
dst->incReserve(n);
@@ -255,7 +256,6 @@ bool SkDashPath::InternalFilter(SkPath* dst, const SkPath& src, SkStrokeRec* rec
// 90 million dash segments and crashing the memory allocator. A limit of 1 million
// segments seems reasonable: at 2 verbs per segment * 9 bytes per verb, this caps the
// maximum dash memory overhead at roughly 17MB per path.
- static const SkScalar kMaxDashCount = 1000000;
dashCount += length * (count >> 1) / intervalLength;
if (dashCount > kMaxDashCount) {
dst->reset();