diff options
author | caryclark <caryclark@google.com> | 2016-07-22 03:34:19 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-07-22 03:34:19 -0700 |
commit | cdeff81bdb2e5cde422b6850634c5d3977fcbae9 (patch) | |
tree | 19fff5f761df4b949c4d894c650674f5fab686c2 /src/pathops/SkPathOpsTSect.h | |
parent | 901257a3ba1d094280b4e1e0868bc0bcd137145a (diff) |
conic fuzz fix
If no closest section is found in conic intersection
(which can happen if the numbers are out of range)
abort the intersection.
Also suppress assert fired in this case so it only
checks intersections with in-range values.
TBR=reed@google.com
BUG=630378
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2166813006
Review-Url: https://codereview.chromium.org/2166813006
Diffstat (limited to 'src/pathops/SkPathOpsTSect.h')
-rw-r--r-- | src/pathops/SkPathOpsTSect.h | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/pathops/SkPathOpsTSect.h b/src/pathops/SkPathOpsTSect.h index 9032af83eb..db2e865a12 100644 --- a/src/pathops/SkPathOpsTSect.h +++ b/src/pathops/SkPathOpsTSect.h @@ -882,6 +882,7 @@ bool SkTSect<TCurve, OppCurve>::binarySearchCoin(SkTSect<OppCurve, TCurve>* sect SkDPoint last = fCurve.ptAtT(tStart); SkDPoint oppPt; bool flip = false; + bool contained = false; SkDEBUGCODE(bool down = tStep < 0); const OppCurve& opp = sect2->fCurve; do { @@ -908,6 +909,7 @@ bool SkTSect<TCurve, OppCurve>::binarySearchCoin(SkTSect<OppCurve, TCurve>* sect if (sect2->fHead->contains(oppTTest)) { *oppT = oppTTest; oppPt = work.fCoinStart.perpPt(); + contained = true; SkASSERT(down ? result > work.fStartT : result < work.fStartT); result = work.fStartT; continue; @@ -916,6 +918,9 @@ bool SkTSect<TCurve, OppCurve>::binarySearchCoin(SkTSect<OppCurve, TCurve>* sect tStep = -tStep; flip = true; } while (true); + if (!contained) { + return false; + } if (last.approximatelyEqual(fCurve[0])) { result = 0; } else if (last.approximatelyEqual(fCurve[TCurve::kPointLast])) { @@ -1923,10 +1928,10 @@ struct SkClosestRecord { fClosest = dist; } - bool matesWith(const SkClosestRecord& mate) const { + bool matesWith(const SkClosestRecord& mate SkDEBUGPARAMS(SkIntersections* i)) const { SkASSERT(fC1Span == mate.fC1Span || fC1Span->endT() <= mate.fC1Span->startT() || mate.fC1Span->endT() <= fC1Span->startT()); - SkASSERT(fC2Span == mate.fC2Span || fC2Span->endT() <= mate.fC2Span->startT() + SkOPOBJASSERT(i, fC2Span == mate.fC2Span || fC2Span->endT() <= mate.fC2Span->startT() || mate.fC2Span->endT() <= fC2Span->startT()); return fC1Span == mate.fC1Span || fC1Span->endT() == mate.fC1Span->startT() || fC1Span->startT() == mate.fC1Span->endT() @@ -1975,7 +1980,8 @@ struct SkClosestSect { fClosest.push_back().reset(); } - bool find(const SkTSpan<TCurve, OppCurve>* span1, const SkTSpan<OppCurve, TCurve>* span2) { + bool find(const SkTSpan<TCurve, OppCurve>* span1, const SkTSpan<OppCurve, TCurve>* span2 + SkDEBUGPARAMS(SkIntersections* i)) { SkClosestRecord<TCurve, OppCurve>* record = &fClosest[fUsed]; record->findEnd(span1, span2, 0, 0); record->findEnd(span1, span2, 0, OppCurve::kPointLast); @@ -1986,7 +1992,7 @@ struct SkClosestSect { } for (int index = 0; index < fUsed; ++index) { SkClosestRecord<TCurve, OppCurve>* test = &fClosest[index]; - if (test->matesWith(*record)) { + if (test->matesWith(*record SkDEBUGPARAMS(i))) { if (test->fClosest > record->fClosest) { test->merge(*record); } @@ -2212,7 +2218,7 @@ void SkTSect<TCurve, OppCurve>::BinarySearch(SkTSect<TCurve, OppCurve>* sect1, SkTSpan<OppCurve, TCurve>* result2 = sect2->fHead; bool found = false; while (result2) { - found |= closest.find(result1, result2); + found |= closest.find(result1, result2 SkDEBUGPARAMS(intersections)); result2 = result2->fNext; } } while ((result1 = result1->fNext)); |