diff options
author | caryclark <caryclark@google.com> | 2016-07-22 10:56:26 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-07-22 10:56:26 -0700 |
commit | 8a8accbcd1958c1646246b9b994fb47a3b5a6021 (patch) | |
tree | 86353e74d8a7fd00c073746029ad0681a8376b25 /src | |
parent | 4c6e47a8a827077e36fa5feb4ab5ac7435d8276b (diff) |
limit number of searched roots
Extreme numbers can generate more than
three found cubic roots when the roots
are found through a binary search.
Fail in this case.
TBR=reed@google.com
BUG=630649
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2176733002
Review-Url: https://codereview.chromium.org/2176733002
Diffstat (limited to 'src')
-rw-r--r-- | src/pathops/SkPathOpsCubic.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/pathops/SkPathOpsCubic.cpp b/src/pathops/SkPathOpsCubic.cpp index 7fd3dd235d..6fcb348e4f 100644 --- a/src/pathops/SkPathOpsCubic.cpp +++ b/src/pathops/SkPathOpsCubic.cpp @@ -310,6 +310,7 @@ int SkDCubic::searchRoots(double extremeTs[6], int extrema, double axisIntercept extrema += findInflections(&extremeTs[extrema]); extremeTs[extrema++] = 0; extremeTs[extrema] = 1; + SkASSERT(extrema < 6); SkTQSort(extremeTs, extremeTs + extrema); int validCount = 0; for (int index = 0; index < extrema; ) { @@ -320,6 +321,9 @@ int SkDCubic::searchRoots(double extremeTs[6], int extrema, double axisIntercept } double newT = binarySearch(min, max, axisIntercept, xAxis); if (newT >= 0) { + if (validCount >= 3) { + return 0; + } validRoots[validCount++] = newT; } } |