add fail condition to addexpanded
authorcaryclark <caryclark@google.com>
Fri, 10 Jun 2016 14:59:50 +0000 (07:59 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 10 Jun 2016 14:59:50 +0000 (07:59 -0700)
If coincident pairs don't match,
give up rather than deref null.

R=fmalita@chromium.org
BUG=618991
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2058773002

Review-Url: https://codereview.chromium.org/2058773002

src/pathops/SkOpCoincidence.cpp
tests/PathOpsBuilderTest.cpp

index 42ee5c6091198b4c1eab57c4a2df45d3c419b815..b72bd6cb37232fdce2534e4479e6107e177de538 100755 (executable)
@@ -136,6 +136,9 @@ bool SkOpCoincidence::addExpanded(SkChunkAlloc* allocator
             }
             if (oTest != oEnd) {
                 oTest = coin->fFlipped ? oTest->prev() : oTest->upCast()->next();
+                if (!oTest) {
+                    return false;
+                }
             }
         }
     } while ((coin = coin->fNext));
index e29b4bc473706550bc4c6aff0de3a1370815914c..8547d850484262175c4424f795d67417349089f3 100644 (file)
@@ -323,3 +323,24 @@ path.lineTo(SkBits2Float(0x42e33333), SkBits2Float(0x42940000));  // 113.6f, 74
     SkPath result;
     builder.resolve(&result);
 }
+
+DEF_TEST(SkOpBuilder618991, reporter) {
+    SkPath path0;
+    path0.moveTo(140, 40);
+    path0.lineTo(200, 210);
+    path0.lineTo(40, 100);
+    path0.lineTo(2.22223e+07f, 2.22222e+14f);
+    path0.lineTo(2.22223e+07f, 2.22222e+14f);
+
+    SkPath path1;
+    path1.moveTo(160, 60);
+    path1.lineTo(220, 230);
+    path1.lineTo(60, 120);
+    path1.lineTo(2.22223e+07f, 2.22222e+14f);
+    path1.lineTo(2.22223e+07f, 2.22222e+14f);
+
+    SkOpBuilder builder;
+    builder.add(path0, SkPathOp::kUnion_SkPathOp);
+    builder.add(path1, SkPathOp::kUnion_SkPathOp);
+    builder.resolve(&path0);
+}