Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(980)

Unified Diff: src/pathops/SkOpBuilder.cpp

Issue 2046713003: fix pathops fuzz bugs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix most vexing parse Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pathops/SkIntersections.h ('k') | src/pathops/SkOpCoincidence.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pathops/SkOpBuilder.cpp
diff --git a/src/pathops/SkOpBuilder.cpp b/src/pathops/SkOpBuilder.cpp
index 4f53dee056645bc9658d6e020bdab4597bf1999a..67aa92fe265586ccc7c8b4d23031924275dae9c6 100644
--- a/src/pathops/SkOpBuilder.cpp
+++ b/src/pathops/SkOpBuilder.cpp
@@ -25,7 +25,7 @@ static bool one_contour(const SkPath& path) {
return true;
}
-void FixWinding(SkPath* path) {
+bool FixWinding(SkPath* path) {
SkPath::FillType fillType = path->getFillType();
if (fillType == SkPath::kInverseEvenOdd_FillType) {
fillType = SkPath::kInverseWinding_FillType;
@@ -40,14 +40,17 @@ void FixWinding(SkPath* path) {
*path = temp;
}
path->setFillType(fillType);
- return;
+ return true;
}
SkChunkAlloc allocator(4096);
SkOpContourHead contourHead;
- SkOpGlobalState globalState(nullptr, &contourHead SkDEBUGPARAMS(nullptr));
+ SkOpGlobalState globalState(nullptr, &contourHead SkDEBUGPARAMS(false)
+ SkDEBUGPARAMS(nullptr));
SkOpEdgeBuilder builder(*path, &contourHead, &allocator, &globalState);
builder.finish(&allocator);
- SkASSERT(contourHead.next());
+ if (!contourHead.next()) {
+ return false;
+ }
contourHead.resetReverse();
bool writePath = false;
SkOpSpan* topSpan;
@@ -69,7 +72,7 @@ void FixWinding(SkPath* path) {
}
if (!writePath) {
path->setFillType(fillType);
- return;
+ return true;
}
SkPath empty;
SkPathWriter woundPath(empty);
@@ -83,6 +86,7 @@ void FixWinding(SkPath* path) {
} while ((test = test->next()));
*path = *woundPath.nativePath();
path->setFillType(fillType);
+ return true;
}
void SkOpBuilder::add(const SkPath& path, SkPathOp op) {
@@ -160,7 +164,10 @@ bool SkOpBuilder::resolve(SkPath* result) {
}
if (!fPathRefs[index].isEmpty()) {
// convert the even odd result back to winding form before accumulating it
- FixWinding(&fPathRefs[index]);
+ if (!FixWinding(&fPathRefs[index])) {
+ *result = original;
+ return false;
+ }
sum.addPath(fPathRefs[index]);
}
}
« no previous file with comments | « src/pathops/SkIntersections.h ('k') | src/pathops/SkOpCoincidence.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698