Don't allow iteration through non-finite points.
Added a unit test too. BUG=chromium:756563 Change-Id: Ic77a89b4a98d1a553877af9807a3d3bdcd077bb9 Reviewed-on: https://skia-review.googlesource.com/44420 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Mike Reed <reed@google.com>
This commit is contained in:
parent
900cd05037
commit
1170a553be
@ -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
|
||||
|
@ -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]) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user