check for NaN in path iterator (otherwise we have an infinite loop)

git-svn-id: http://skia.googlecode.com/svn/trunk@131 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@android.com 2009-03-20 12:16:09 +00:00
parent 797d51acd2
commit 4ddfe357da

View File

@ -989,6 +989,14 @@ bool SkPath::Iter::isClosedContour() const {
SkPath::Verb SkPath::Iter::autoClose(SkPoint pts[2]) {
if (fLastPt != fMoveTo) {
// A special case: if both points are NaN, SkPoint::operation== returns
// false, but the iterator expects that they are treated as the same.
// (consider SkPoint is a 2-dimension float point).
if (SkScalarIsNaN(fLastPt.fX) && SkScalarIsNaN(fLastPt.fY) &&
SkScalarIsNaN(fMoveTo.fX) && SkScalarIsNaN(fMoveTo.fY)) {
return kClose_Verb;
}
if (pts) {
pts[0] = fLastPt;
pts[1] = fMoveTo;