diff options
author | caryclark <caryclark@google.com> | 2016-10-17 07:54:33 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-10-17 07:54:33 -0700 |
commit | e6522ea38fa3bcfdf2d718ea5ad898b3b3d46e00 (patch) | |
tree | 125cefeb19f9ec7cd1b660bb6de767eb3801142d /src/pathops | |
parent | 862a3876086a9367c584598038887b94d8065fd7 (diff) |
fix some fuzz
TBR=reed@google.com
BUG=654939, 655829, 656149
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2425733002
Review-Url: https://codereview.chromium.org/2425733002
Diffstat (limited to 'src/pathops')
-rwxr-xr-x | src/pathops/SkOpCoincidence.cpp | 12 | ||||
-rw-r--r-- | src/pathops/SkOpCoincidence.h | 2 | ||||
-rwxr-xr-x | src/pathops/SkOpSpan.cpp | 4 | ||||
-rw-r--r-- | src/pathops/SkPathOpsCommon.cpp | 4 | ||||
-rw-r--r-- | src/pathops/SkPathOpsDebug.cpp | 25 |
5 files changed, 16 insertions, 31 deletions
diff --git a/src/pathops/SkOpCoincidence.cpp b/src/pathops/SkOpCoincidence.cpp index 8734cb0d92..aa5f5bfba7 100755 --- a/src/pathops/SkOpCoincidence.cpp +++ b/src/pathops/SkOpCoincidence.cpp @@ -1262,14 +1262,16 @@ void SkOpCoincidence::fixUp(SkCoincidentSpans* coin, SkOpPtT* deleted, const SkO // Please keep this in sync with debugMark() /* this sets up the coincidence links in the segments when the coincidence crosses multiple spans */ -void SkOpCoincidence::mark(DEBUG_COIN_DECLARE_ONLY_PARAMS()) { +bool SkOpCoincidence::mark(DEBUG_COIN_DECLARE_ONLY_PARAMS()) { DEBUG_SET_PHASE(); SkCoincidentSpans* coin = fHead; if (!coin) { - return; + return true; } do { - SkOpSpan* start = coin->coinPtTStartWritable()->span()->upCast(); + SkOpSpanBase* startBase = coin->coinPtTStartWritable()->span(); + FAIL_IF(!startBase->upCastable()); + SkOpSpan* start = startBase->upCast(); SkASSERT(!start->deleted()); SkOpSpanBase* end = coin->coinPtTEndWritable()->span(); SkOPASSERT(!end->deleted()); @@ -1291,12 +1293,14 @@ void SkOpCoincidence::mark(DEBUG_COIN_DECLARE_ONLY_PARAMS()) { SkOpSpanBase* oNext = oStart; bool ordered = coin->ordered(); while ((next = next->upCast()->next()) != end) { + FAIL_IF(!next->upCastable()); SkAssertResult(next->upCast()->insertCoincidence(oSegment, flipped, ordered)); } while ((oNext = oNext->upCast()->next()) != oEnd) { - SkAssertResult(oNext->upCast()->insertCoincidence(segment, flipped, ordered)); + FAIL_IF(!oNext->upCast()->insertCoincidence(segment, flipped, ordered)); } } while ((coin = coin->next())); + return true; } // Please keep in sync with debugMarkCollapsed() diff --git a/src/pathops/SkOpCoincidence.h b/src/pathops/SkOpCoincidence.h index 3f8816e45c..e2188bebbd 100644 --- a/src/pathops/SkOpCoincidence.h +++ b/src/pathops/SkOpCoincidence.h @@ -227,7 +227,7 @@ public: return !fHead && !fTop; } - void mark(DEBUG_COIN_DECLARE_ONLY_PARAMS()); + bool mark(DEBUG_COIN_DECLARE_ONLY_PARAMS()); void markCollapsed(SkOpPtT* ); static bool Ordered(const SkOpPtT* coinPtTStart, const SkOpPtT* oppPtTStart) { diff --git a/src/pathops/SkOpSpan.cpp b/src/pathops/SkOpSpan.cpp index 2abc44e248..40d6383c74 100755 --- a/src/pathops/SkOpSpan.cpp +++ b/src/pathops/SkOpSpan.cpp @@ -407,7 +407,9 @@ bool SkOpSpan::insertCoincidence(const SkOpSegment* segment, bool flipped, bool SkOpSpan* span; SkOpSpanBase* base = next->span(); if (!ordered) { - const SkOpSpanBase* spanEnd = fNext->contains(segment)->span(); + const SkOpPtT* spanEndPtT = fNext->contains(segment); + FAIL_IF(!spanEndPtT); + const SkOpSpanBase* spanEnd = spanEndPtT->span(); const SkOpPtT* start = base->ptT()->starter(spanEnd->ptT()); FAIL_IF(!start->span()->upCastable()); span = const_cast<SkOpSpan*>(start->span()->upCast()); diff --git a/src/pathops/SkPathOpsCommon.cpp b/src/pathops/SkPathOpsCommon.cpp index b0a24a7094..b4049bc5d9 100644 --- a/src/pathops/SkPathOpsCommon.cpp +++ b/src/pathops/SkPathOpsCommon.cpp @@ -302,7 +302,9 @@ bool HandleCoincidence(SkOpContourHead* contourList, SkOpCoincidence* coincidenc if (!coincidence->addExpanded(DEBUG_COIN_ONLY_PARAMS())) { return false; } - coincidence->mark(DEBUG_PHASE_ONLY_PARAMS(kWalking)); + if (!coincidence->mark(DEBUG_PHASE_ONLY_PARAMS(kWalking))) { + return false; + } } else { (void) coincidence->expand(DEBUG_COIN_ONLY_PARAMS()); } diff --git a/src/pathops/SkPathOpsDebug.cpp b/src/pathops/SkPathOpsDebug.cpp index e744c75658..a0fcff58e0 100644 --- a/src/pathops/SkPathOpsDebug.cpp +++ b/src/pathops/SkPathOpsDebug.cpp @@ -277,7 +277,7 @@ static void move_nearby(SkPathOpsDebug::GlitchLog* glitches, const SkOpContourHe void SkOpGlobalState::debugAddToCoinChangedDict() { #if DEBUG_COINCIDENCE - CheckHealth(contourList); + SkPathOpsDebug::CheckHealth(fContourHead); #endif // see if next coincident operation makes a change; if so, record it SkPathOpsDebug::GlitchLog glitches; @@ -477,14 +477,6 @@ void SkPathOpsDebug::MathematicaIze(char* str, size_t bufferLen) { } } -#if DEBUG_VALIDATE -void SkPathOpsDebug::SetPhase(SkOpContourHead* contourList, CoinID next, - int lineNumber, SkOpPhase phase) { - AddedCoin(contourList, next, 0, lineNumber); - contourList->globalState()->setPhase(phase); -} -#endif - bool SkPathOpsDebug::ValidWind(int wind) { return wind > SK_MinS32 + 0xFFFF && wind < SK_MaxS32 - 0xFFFF; } @@ -1688,21 +1680,6 @@ void SkOpCoincidence::debugAddExpanded(SkPathOpsDebug::GlitchLog* log) const { return; } -/* Commented-out lines keep this in sync with addIfMissing() */ -void SkOpCoincidence::debugAddIfMissing(SkPathOpsDebug::GlitchLog* log, const SkCoincidentSpans* outer, const SkOpPtT* over1s, - const SkOpPtT* over1e) const { -// SkASSERT(fTop); - if (fTop && alreadyAdded(fTop, outer, over1s, over1e)) { // in debug, fTop may be null - return; - } - if (fHead && alreadyAdded(fHead, outer, over1s, over1e)) { - return; - } - log->record(SkPathOpsDebug::kAddIfMissingCoin_Glitch, outer->coinPtTStart(), outer->coinPtTEnd(), over1s, over1e); - this->debugValidate(); - return; -} - /* Commented-out lines keep this in sync addIfMissing() */ // note that over1s, over1e, over2s, over2e are ordered void SkOpCoincidence::debugAddIfMissing(SkPathOpsDebug::GlitchLog* log, const SkOpPtT* over1s, const SkOpPtT* over2s, |