From a35ab3e6e024d0b548ded26a2e3b8ecd838ead93 Mon Sep 17 00:00:00 2001 From: caryclark Date: Thu, 20 Oct 2016 08:32:18 -0700 Subject: fix fuzzers Many old pathops-related fuzz failures have built up while the codebase was under a state a flux. Now that the code is stable, address these failures. Most of the CL plumbs the debug global state to downstream routines so that, if the data is not trusted (ala fuzzed) the function can safely exit without asserting. TBR=reed@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2426173002 Review-Url: https://chromiumcodereview.appspot.com/2426173002 --- tests/PathOpsCubicLineIntersectionIdeas.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'tests/PathOpsCubicLineIntersectionIdeas.cpp') diff --git a/tests/PathOpsCubicLineIntersectionIdeas.cpp b/tests/PathOpsCubicLineIntersectionIdeas.cpp index b23dd0ceaf..15554751da 100644 --- a/tests/PathOpsCubicLineIntersectionIdeas.cpp +++ b/tests/PathOpsCubicLineIntersectionIdeas.cpp @@ -16,7 +16,7 @@ static bool gPathOpsCubicLineIntersectionIdeasVerbose = false; static struct CubicLineFailures { - SkDCubic c; + CubicPts c; double t; SkDPoint p; } cubicLineFailures[] = { @@ -145,13 +145,15 @@ DEF_TEST(PathOpsCubicLineRoots, reporter) { double largestR2 = 0; for (int index = 0; index < 1000000000; ++index) { SkDPoint origin = {ran.nextRangeF(-1000, 1000), ran.nextRangeF(-1000, 1000)}; - SkDCubic cubic = {{origin, + CubicPts cuPts = {{origin, {ran.nextRangeF(-1000, 1000), ran.nextRangeF(-1000, 1000)}, {ran.nextRangeF(-1000, 1000), ran.nextRangeF(-1000, 1000)}, {ran.nextRangeF(-1000, 1000), ran.nextRangeF(-1000, 1000)} }}; // construct a line at a known intersection double t = ran.nextRangeF(0, 1); + SkDCubic cubic; + cubic.debugSet(cuPts.fPts); SkDPoint pt = cubic.ptAtT(t); // skip answers with no intersections (although note the bug!) or two, or more // see if the line / cubic has a fun range of roots @@ -248,7 +250,9 @@ DEF_TEST(PathOpsCubicLineRoots, reporter) { } static double testOneFailure(const CubicLineFailures& failure) { - const SkDCubic& cubic = failure.c; + const CubicPts& c = failure.c; + SkDCubic cubic; + cubic.debugSet(c.fPts); const SkDPoint& pt = failure.p; double A, B, C, D; SkDCubic::Coefficients(&cubic[0].fY, &A, &B, &C, &D); -- cgit v1.2.3