Fix for rare crash in Poly::addEdge().
Don't add an edge if the bottom vertex was already added, or
if an island vertex has a left poly but no right poly.
(Sorry for the lack of test, but the only reduction I could create was still a huge path and only crashes in Chrome.)
BUG=617907
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2043873005
Review-Url: https://codereview.chromium.org/2043873005
diff --git a/src/gpu/GrTessellator.cpp b/src/gpu/GrTessellator.cpp
index 25d1bb3..fc09c0c 100644
--- a/src/gpu/GrTessellator.cpp
+++ b/src/gpu/GrTessellator.cpp
@@ -418,13 +418,12 @@
if (!fTail) {
fHead = fTail = ALLOC_NEW(MonotonePoly, (e, side), alloc);
fCount += 2;
+ } else if (e->fBottom == fTail->fLastEdge->fBottom) {
+ return poly;
} else if (side == fTail->fSide) {
fTail->addEdge(e);
fCount++;
} else {
- if (e->fBottom == fTail->fLastEdge->fBottom) {
- return poly;
- }
e = ALLOC_NEW(Edge, (fTail->fLastEdge->fBottom, e->fBottom, 1), alloc);
fTail->addEdge(e);
fCount++;
@@ -1240,7 +1239,7 @@
}
if (v->fFirstEdgeBelow) {
if (!v->fFirstEdgeAbove) {
- if (leftPoly) {
+ if (leftPoly && rightPoly) {
if (leftPoly == rightPoly) {
if (leftPoly->fTail && leftPoly->fTail->fSide == Poly::kLeft_Side) {
leftPoly = new_poly(&polys, leftPoly->lastVertex(),