fix fuzz timeout in pathops
R=kjlubick@google.com
Bug:910097
Change-Id: I5a848db8bb0b57d296c119201ad35d5d66df8408
Reviewed-on: https://skia-review.googlesource.com/c/173362
Commit-Queue: Cary Clark <caryclark@skia.org>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Auto-Submit: Cary Clark <caryclark@skia.org>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
diff --git a/src/pathops/SkOpSpan.cpp b/src/pathops/SkOpSpan.cpp
index 9fa05f1..a68133e 100644
--- a/src/pathops/SkOpSpan.cpp
+++ b/src/pathops/SkOpSpan.cpp
@@ -149,14 +149,15 @@
fDeleted = true;
}
-void SkOpSpanBase::addOpp(SkOpSpanBase* opp) {
+bool SkOpSpanBase::addOpp(SkOpSpanBase* opp) {
SkOpPtT* oppPrev = this->ptT()->oppPrev(opp->ptT());
if (!oppPrev) {
- return;
+ return true;
}
- this->mergeMatches(opp);
+ FAIL_IF(!this->mergeMatches(opp));
this->ptT()->addOpp(opp->ptT(), oppPrev);
this->checkForCollapsedCoincidence();
+ return true;
}
SkOpSpanBase::Collapsed SkOpSpanBase::collapsed(double s, double e) const {
@@ -303,11 +304,15 @@
// merge them
// keep the points, but remove spans so that the segment doesn't have 2 or more
// spans pointing to the same pt-t loop at different loop elements
-void SkOpSpanBase::mergeMatches(SkOpSpanBase* opp) {
+bool SkOpSpanBase::mergeMatches(SkOpSpanBase* opp) {
SkOpPtT* test = &fPtT;
SkOpPtT* testNext;
const SkOpPtT* stop = test;
+ int safetyHatch = 1000000;
do {
+ if (!--safetyHatch) {
+ return false;
+ }
testNext = test->next();
if (test->deleted()) {
continue;
@@ -361,6 +366,7 @@
} while ((inner = inner->next()) != innerStop);
} while ((test = testNext) != stop);
this->checkForCollapsedCoincidence();
+ return true;
}
int SkOpSpan::computeWindSum() {