diff options
-rw-r--r-- | include/private/SkPathRef.h | 2 | ||||
-rw-r--r-- | src/core/SkPathRef.cpp | 7 | ||||
-rw-r--r-- | tests/PathTest.cpp | 15 |
3 files changed, 23 insertions, 1 deletions
diff --git a/include/private/SkPathRef.h b/include/private/SkPathRef.h index 6d353089b0..aa01810890 100644 --- a/include/private/SkPathRef.h +++ b/include/private/SkPathRef.h @@ -124,6 +124,8 @@ public: /** Return the next verb in this iteration of the path. When all segments have been visited, return kDone_Verb. + If any point in the path is non-finite, return kDone_Verb immediately. + @param pts The points representing the current verb and/or segment This must not be NULL. @return The verb for the current segment diff --git a/src/core/SkPathRef.cpp b/src/core/SkPathRef.cpp index 5894b0522b..46f26606ee 100644 --- a/src/core/SkPathRef.cpp +++ b/src/core/SkPathRef.cpp @@ -298,7 +298,7 @@ SkPathRef* SkPathRef::CreateFromBuffer(SkRBuffer* buffer) { return nullptr; } } - + ref->fBoundsIsDirty = false; // resetToSize clears fSegmentMask and fIsOval @@ -691,6 +691,11 @@ void SkPathRef::Iter::setPathRef(const SkPathRef& path) { if (fConicWeights) { fConicWeights -= 1; // begin one behind } + + // Don't allow iteration through non-finite points. + if (!path.isFinite()) { + fVerbStop = fVerbs; + } } uint8_t SkPathRef::Iter::next(SkPoint pts[4]) { diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp index bdd15fbfb3..77f47bed30 100644 --- a/tests/PathTest.cpp +++ b/tests/PathTest.cpp @@ -4911,3 +4911,18 @@ DEF_TEST(PathRefSerialization, reporter) { REPORTER_ASSERT(reporter, !bytesRead); } } + +DEF_TEST(NonFinitePathIteration, reporter) { + SkPath path; + path.moveTo(SK_ScalarInfinity, SK_ScalarInfinity); + + int verbs = 0; + + SkPath::RawIter iter(path); + SkPoint pts[4]; + while (iter.next(pts) != SkPath::kDone_Verb) { + verbs++; + } + + REPORTER_ASSERT(reporter, verbs == 0); +} |