Reject degenerate quads in AA hairline path renderer

Includes unit test that reproduces the original bug.

Bug: chromium:1232834
Change-Id: Iae2f52b42d35f0774c4cf9fa686df7aaf57c130a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/433279
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/src/gpu/ops/GrAAHairLinePathRenderer.cpp b/src/gpu/ops/GrAAHairLinePathRenderer.cpp
index e60558e..d128092 100644
--- a/src/gpu/ops/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/ops/GrAAHairLinePathRenderer.cpp
@@ -1266,6 +1266,9 @@
         int unsubdivQuadCnt = quads.count() / 3;
         for (int i = 0; i < unsubdivQuadCnt; ++i) {
             SkASSERT(qSubdivs[i] >= 0);
+            if (!quads[3*i].isFinite() || !quads[3*i+1].isFinite() || !quads[3*i+2].isFinite()) {
+                return;
+            }
             add_quads(&quads[3*i], qSubdivs[i], toDevice, toSrc, &bezVerts);
         }
 
diff --git a/tests/GpuDrawPathTest.cpp b/tests/GpuDrawPathTest.cpp
index f3e5dc3..d71ea2f 100644
--- a/tests/GpuDrawPathTest.cpp
+++ b/tests/GpuDrawPathTest.cpp
@@ -112,3 +112,21 @@
     surface->getCanvas()->drawPath(path, paint);
     surface->flushAndSubmit();
 }
+
+DEF_GPUTEST_FOR_ALL_CONTEXTS(PathTest_CrBug1232834, reporter, ctxInfo) {
+    // GrAAHairlinePathRenderer chops this path to quads that include infinities (and then NaNs).
+    // It used to trigger asserts, now the degenerate quad segments should cause it to be rejected.
+    SkImageInfo info = SkImageInfo::MakeN32Premul(256, 256);
+    auto surface(SkSurface::MakeRenderTarget(ctxInfo.directContext(), SkBudgeted::kNo, info));
+
+    SkPaint paint;
+    paint.setAntiAlias(true);
+    paint.setStyle(SkPaint::kStroke_Style);
+
+    SkPath path;
+    path.moveTo(9.0072E15f, 60);
+    path.cubicTo(0, 3.40282e+38f, 0, 3.40282e+38f, 0, 0);
+
+    surface->getCanvas()->drawPath(path, paint);
+    surface->flushAndSubmit();
+}