aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pathops
diff options
context:
space:
mode:
authorGravatar Cary Clark <caryclark@skia.org>2018-06-25 08:45:40 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-25 13:10:45 +0000
commitc050a1a185bf13ec19eb8bf62ccf3f73a85a39b2 (patch)
tree4734db0634f5ad3f26a6803e4e633d13b08ced0c /src/pathops
parentc4e72a4d5a9cfc583804fce6c029696cb173a904 (diff)
fix pathop fuzz timeout
R=caryclark@google.com Bug:855751 Change-Id: Ieb6bae50311f62c9b03b84b2cf84f09ad2db2e46 Reviewed-on: https://skia-review.googlesource.com/137361 Reviewed-by: Cary Clark <caryclark@skia.org> Commit-Queue: Cary Clark <caryclark@skia.org> Auto-Submit: Cary Clark <caryclark@skia.org>
Diffstat (limited to 'src/pathops')
-rw-r--r--src/pathops/SkOpSegment.cpp20
-rw-r--r--src/pathops/SkOpSegment.h2
-rw-r--r--src/pathops/SkPathOpsOp.cpp5
-rw-r--r--src/pathops/SkPathOpsSimplify.cpp5
4 files changed, 24 insertions, 8 deletions
diff --git a/src/pathops/SkOpSegment.cpp b/src/pathops/SkOpSegment.cpp
index bfbf9dc687..3bd925c0c3 100644
--- a/src/pathops/SkOpSegment.cpp
+++ b/src/pathops/SkOpSegment.cpp
@@ -599,7 +599,7 @@ SkOpSegment* SkOpSegment::findNextOp(SkTDArray<SkOpSpanBase*>* chase, SkOpSpanBa
continue;
}
if (!activeAngle) {
- (void) nextSegment->markAndChaseDone(nextAngle->start(), nextAngle->end());
+ (void) nextSegment->markAndChaseDone(nextAngle->start(), nextAngle->end(), nullptr);
}
SkOpSpanBase* last = nextAngle->lastMarked();
if (last) {
@@ -695,7 +695,7 @@ SkOpSegment* SkOpSegment::findNextWinding(SkTDArray<SkOpSpanBase*>* chase,
continue;
}
if (!activeAngle) {
- (void) nextSegment->markAndChaseDone(nextAngle->start(), nextAngle->end());
+ (void) nextSegment->markAndChaseDone(nextAngle->start(), nextAngle->end(), nullptr);
}
SkOpSpanBase* last = nextAngle->lastMarked();
if (last) {
@@ -843,7 +843,7 @@ void SkOpSegment::markAllDone() {
} while ((span = span->next()->upCastable()));
}
-SkOpSpanBase* SkOpSegment::markAndChaseDone(SkOpSpanBase* start, SkOpSpanBase* end) {
+ bool SkOpSegment::markAndChaseDone(SkOpSpanBase* start, SkOpSpanBase* end, SkOpSpanBase** found) {
int step = start->step(end);
SkOpSpan* minSpan = start->starter(end);
markDone(minSpan);
@@ -851,19 +851,29 @@ SkOpSpanBase* SkOpSegment::markAndChaseDone(SkOpSpanBase* start, SkOpSpanBase* e
SkOpSegment* other = this;
SkOpSpan* priorDone = nullptr;
SkOpSpan* lastDone = nullptr;
+ int safetyNet = 100000;
while ((other = other->nextChase(&start, &step, &minSpan, &last))) {
+ if (!--safetyNet) {
+ return false;
+ }
if (other->done()) {
SkASSERT(!last);
break;
}
if (lastDone == minSpan || priorDone == minSpan) {
- return nullptr;
+ if (found) {
+ *found = nullptr;
+ }
+ return true;
}
other->markDone(minSpan);
priorDone = lastDone;
lastDone = minSpan;
}
- return last;
+ if (found) {
+ *found = last;
+ }
+ return true;
}
bool SkOpSegment::markAndChaseWinding(SkOpSpanBase* start, SkOpSpanBase* end, int winding,
diff --git a/src/pathops/SkOpSegment.h b/src/pathops/SkOpSegment.h
index a68b30a289..a38d785250 100644
--- a/src/pathops/SkOpSegment.h
+++ b/src/pathops/SkOpSegment.h
@@ -274,7 +274,7 @@ public:
}
void markAllDone();
- SkOpSpanBase* markAndChaseDone(SkOpSpanBase* start, SkOpSpanBase* end);
+ bool markAndChaseDone(SkOpSpanBase* start, SkOpSpanBase* end, SkOpSpanBase** found);
bool markAndChaseWinding(SkOpSpanBase* start, SkOpSpanBase* end, int winding,
SkOpSpanBase** lastPtr);
bool markAndChaseWinding(SkOpSpanBase* start, SkOpSpanBase* end, int winding,
diff --git a/src/pathops/SkPathOpsOp.cpp b/src/pathops/SkPathOpsOp.cpp
index 09c6f0e1ce..f8b8a65eec 100644
--- a/src/pathops/SkPathOpsOp.cpp
+++ b/src/pathops/SkPathOpsOp.cpp
@@ -157,7 +157,10 @@ static bool bridgeOp(SkOpContourHead* contourList, const SkPathOp op,
}
simple->finishContour();
} else {
- SkOpSpanBase* last = current->markAndChaseDone(start, end);
+ SkOpSpanBase* last;
+ if (!current->markAndChaseDone(start, end, &last)) {
+ return false;
+ }
if (last && !last->chased()) {
last->setChased(true);
SkASSERT(!SkPathOpsDebug::ChaseContains(chase, last));
diff --git a/src/pathops/SkPathOpsSimplify.cpp b/src/pathops/SkPathOpsSimplify.cpp
index d9d0879986..bfb3b8d7c1 100644
--- a/src/pathops/SkPathOpsSimplify.cpp
+++ b/src/pathops/SkPathOpsSimplify.cpp
@@ -58,7 +58,10 @@ static bool bridgeWinding(SkOpContourHead* contourList, SkPathWriter* simple) {
}
simple->finishContour();
} else {
- SkOpSpanBase* last = current->markAndChaseDone(start, end);
+ SkOpSpanBase* last;
+ if (!current->markAndChaseDone(start, end, &last)) {
+ return false;
+ }
if (last && !last->chased()) {
last->setChased(true);
SkASSERT(!SkPathOpsDebug::ChaseContains(chase, last));