aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pathops
diff options
context:
space:
mode:
authorGravatar Cary Clark <caryclark@google.com>2016-12-08 16:17:56 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-12-08 22:22:12 +0000
commit59ed482af72beec6812b28d833d8bdf80ba32df7 (patch)
tree7f993451a2ed6eada726393f3067bae1f2dcfe82 /src/pathops
parent8e7432b7f98dd592e529a0c8bb038d73ebfb0478 (diff)
fix fuzzers
Two crashes and a hang. Abort and return false in these cases. TBR=kjlubick@google.com BUG=skia:5983 Change-Id: I41ac3e56d47ee423b634b2f4886085b9caada76b Reviewed-on: https://skia-review.googlesource.com/5716 Reviewed-by: Cary Clark <caryclark@google.com> Reviewed-by: Kevin Lubick <kjlubick@google.com> Commit-Queue: Cary Clark <caryclark@google.com>
Diffstat (limited to 'src/pathops')
-rw-r--r--src/pathops/SkOpCoincidence.cpp2
-rw-r--r--src/pathops/SkPathOpsTSect.h10
2 files changed, 11 insertions, 1 deletions
diff --git a/src/pathops/SkOpCoincidence.cpp b/src/pathops/SkOpCoincidence.cpp
index d7ef35f5c4..1ade4446a3 100644
--- a/src/pathops/SkOpCoincidence.cpp
+++ b/src/pathops/SkOpCoincidence.cpp
@@ -1314,7 +1314,7 @@ bool SkOpCoincidence::mark(DEBUG_COIN_DECLARE_ONLY_PARAMS()) {
FAIL_IF(!coin->ordered(&ordered));
while ((next = next->upCast()->next()) != end) {
FAIL_IF(!next->upCastable());
- SkAssertResult(next->upCast()->insertCoincidence(oSegment, flipped, ordered));
+ FAIL_IF(!next->upCast()->insertCoincidence(oSegment, flipped, ordered));
}
while ((oNext = oNext->upCast()->next()) != oEnd) {
FAIL_IF(!oNext->upCastable());
diff --git a/src/pathops/SkPathOpsTSect.h b/src/pathops/SkPathOpsTSect.h
index f3402daa67..5d74c9a998 100644
--- a/src/pathops/SkPathOpsTSect.h
+++ b/src/pathops/SkPathOpsTSect.h
@@ -1162,6 +1162,7 @@ template<typename TCurve, typename OppCurve>
bool SkTSect<TCurve, OppCurve>::deleteEmptySpans() {
SkTSpan<TCurve, OppCurve>* test;
SkTSpan<TCurve, OppCurve>* next = fHead;
+ int safetyHatch = 1000;
while ((test = next)) {
next = test->fNext;
if (!test->fBounded) {
@@ -1169,6 +1170,9 @@ bool SkTSect<TCurve, OppCurve>::deleteEmptySpans() {
return false;
}
}
+ if (--safetyHatch < 0) {
+ return false;
+ }
}
return true;
}
@@ -2234,7 +2238,13 @@ void SkTSect<TCurve, OppCurve>::BinarySearch(SkTSect<TCurve, OppCurve>* sect1,
}
if (sect1->fActiveCount >= COINCIDENT_SPAN_COUNT
&& sect2->fActiveCount >= COINCIDENT_SPAN_COUNT) {
+ if (!sect1->fHead) {
+ return;
+ }
sect1->computePerpendiculars(sect2, sect1->fHead, sect1->tail());
+ if (!sect2->fHead) {
+ return;
+ }
sect2->computePerpendiculars(sect1, sect2->fHead, sect2->tail());
sect1->removeByPerpendicular(sect2);
sect1->validate();