path ops: fix fuzz-found divide by zero

TBR=reed@google.com
BUG=542391

Review URL: https://codereview.chromium.org/1427913005
This commit is contained in:
caryclark 2015-11-02 07:32:58 -08:00 committed by Commit bot
parent 574a4c153d
commit 952ebfe228
2 changed files with 32 additions and 0 deletions

View File

@ -91,8 +91,14 @@ bool SkOpCoincidence::addExpanded(SkChunkAlloc* allocator
if (!test->ptT()->contains(oTest->ptT())) {
// use t ranges to guess which one is missing
double startRange = coin->fCoinPtTEnd->fT - startPtT->fT;
if (!startRange) {
return false;
}
double startPart = (test->t() - startPtT->fT) / startRange;
double oStartRange = coin->fOppPtTEnd->fT - oStartPtT->fT;
if (!oStartRange) {
return false;
}
double oStartPart = (oTest->t() - oStartPtT->fT) / oStartRange;
if (startPart == oStartPart) {
return false;

View File

@ -5755,7 +5755,33 @@ path.close();
testPathFailOp(reporter, path1, path2, (SkPathOp) 2, filename);
}
static void fuzz753_91(skiatest::Reporter* reporter, const char* filename) {
SkPath path;
path.setFillType((SkPath::FillType) 0);
path.moveTo(SkBits2Float(0x42910000), SkBits2Float(0x00000000)); // 72.5f, 0
path.lineTo(SkBits2Float(0x42166668), SkBits2Float(0x00000000)); // 37.6f, 0
path.cubicTo(SkBits2Float(0x42166668), SkBits2Float(0xc1966668), SkBits2Float(0x41c66668), SkBits2Float(0xc20a6666), SkBits2Float(0x40f00010), SkBits2Float(0xc21ccccd)); // 37.6f, -18.8f, 24.8f, -34.6f, 7.50001f, -39.2f
path.lineTo(SkBits2Float(0x41840004), SkBits2Float(0xc291cccd)); // 16.5f, -72.9f
path.lineTo(SkBits2Float(0x42fb6668), SkBits2Float(0x42c73334)); // 125.7f, 99.6f
path.lineTo(SkBits2Float(0x43646668), SkBits2Float(0x43880ccd)); // 228.4f, 272.1f
SkPath path1(path);
path.reset();
path.setFillType((SkPath::FillType) 0);
path.moveTo(SkBits2Float(0x428bf702), SkBits2Float(0xcf223cbf)); // 69.9824f, -2.72189e+09f
path.lineTo(SkBits2Float(0x42112d68), SkBits2Float(0xcf223cbf)); // 36.2943f, -2.72189e+09f
path.cubicTo(SkBits2Float(0x4220d9fc), SkBits2Float(0xcf223cc0), SkBits2Float(0x420ee118), SkBits2Float(0xcf223cc0), SkBits2Float(0x41cef2f8), SkBits2Float(0xcf223cc0)); // 40.2129f, -2.72189e+09f, 35.7198f, -2.72189e+09f, 25.8686f, -2.72189e+09f
path.lineTo(SkBits2Float(0x424a99e0), SkBits2Float(0xcf223cc0)); // 50.6503f, -2.72189e+09f
path.cubicTo(SkBits2Float(0x42266e32), SkBits2Float(0xcf223cc0), SkBits2Float(0x41f0fa20), SkBits2Float(0xcf223cc0), SkBits2Float(0x41872ed4), SkBits2Float(0xcf223cc0)); // 41.6076f, -2.72189e+09f, 30.1221f, -2.72189e+09f, 16.8979f, -2.72189e+09f
path.lineTo(SkBits2Float(0x40f8fbe0), SkBits2Float(0xcf223cc0)); // 7.78075f, -2.72189e+09f
SkPath path2(path);
testPathFailOp(reporter, path1, path2, (SkPathOp) 2, filename);
}
static struct TestDesc failTests[] = {
TEST(fuzz753_91),
TEST(fuzz714),
TEST(fuzz487a),
TEST(fuzz433),