diff --git a/fuzz/FuzzCommon.cpp b/fuzz/FuzzCommon.cpp index 8176d7fb55..d6aa94eb86 100644 --- a/fuzz/FuzzCommon.cpp +++ b/fuzz/FuzzCommon.cpp @@ -83,24 +83,33 @@ void FuzzPath(Fuzz* fuzz, SkPath* path, int maxOps) { path->close(); break; case 13: - fuzz->next(&r, &dir); + fuzz->next(&r); + fuzz->nextRange(&ui, 0, 1); + dir = static_cast(ui); path->addRect(r, dir); break; case 14: - fuzz->next(&r, &dir, &ui); + fuzz->nextRange(&ui, 0, 1); + dir = static_cast(ui); + fuzz->next(&r, &ui); path->addRect(r, dir, ui); break; case 15: - fuzz->next(&r, &dir); + fuzz->nextRange(&ui, 0, 1); + dir = static_cast(ui); + fuzz->next(&r); path->addOval(r, dir); break; case 16: - fuzz->next(&r, &dir, &ui); + fuzz->nextRange(&ui, 0, 1); + dir = static_cast(ui); + fuzz->next(&r, &ui); path->addOval(r, dir, ui); break; case 17: + fuzz->nextRange(&ui, 0, 1); + dir = static_cast(ui); fuzz_nice_float(fuzz, &a, &b, &c); - fuzz->next(&dir); path->addCircle(a, b, c, dir); break; case 18: @@ -110,27 +119,35 @@ void FuzzPath(Fuzz* fuzz, SkPath* path, int maxOps) { break; case 19: fuzz_nice_float(fuzz, &a, &b); - fuzz->next(&r, &dir); + fuzz->next(&r); + fuzz->nextRange(&ui, 0, 1); + dir = static_cast(ui); path->addRoundRect(r, a, b, dir); break; case 20: - fuzz->next(&rr, &dir); + fuzz->next(&rr); + fuzz->nextRange(&ui, 0, 1); + dir = static_cast(ui); path->addRRect(rr, dir); break; case 21: - fuzz->next(&rr, &dir, &ui); + fuzz->nextRange(&ui, 0, 1); + dir = static_cast(ui); + fuzz->next(&rr, &ui); path->addRRect(rr, dir, ui); break; case 22: { - SkPath::AddPathMode mode; - fuzz->next(&m, &mode); + fuzz->nextRange(&ui, 0, 1); + SkPath::AddPathMode mode = static_cast(ui); + fuzz->next(&m); FuzzPath(fuzz, &p, maxOps-1); path->addPath(p, m, mode); break; } case 23: { - SkPath::AddPathMode mode; - fuzz->next(&m, &mode); + fuzz->nextRange(&ui, 0, 1); + SkPath::AddPathMode mode = static_cast(ui); + fuzz->next(&m); path->addPath(*path, m, mode); break; } diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp index 34704774b0..2808c12ed4 100644 --- a/src/core/SkPath.cpp +++ b/src/core/SkPath.cpp @@ -1708,14 +1708,21 @@ SkPath& SkPath::reversePathTo(const SkPath& path) { return *this; } -SkPath& SkPath::reverseAddPath(const SkPath& src) { - SkPathRef::Editor ed(&fPathRef, src.fPathRef->countPoints(), src.fPathRef->countVerbs()); +SkPath& SkPath::reverseAddPath(const SkPath& srcPath) { + // Detect if we're trying to add ourself + const SkPath* src = &srcPath; + SkTLazy tmp; + if (this == src) { + src = tmp.set(srcPath); + } - const SkPoint* pts = src.fPathRef->pointsEnd(); + SkPathRef::Editor ed(&fPathRef, src->fPathRef->countPoints(), src->fPathRef->countVerbs()); + + const SkPoint* pts = src->fPathRef->pointsEnd(); // we will iterator through src's verbs backwards - const uint8_t* verbs = src.fPathRef->verbsMemBegin(); // points at the last verb - const uint8_t* verbsEnd = src.fPathRef->verbs(); // points just past the first verb - const SkScalar* conicWeights = src.fPathRef->conicWeightsEnd(); + const uint8_t* verbs = src->fPathRef->verbsMemBegin(); // points at the last verb + const uint8_t* verbsEnd = src->fPathRef->verbs(); // points just past the first verb + const SkScalar* conicWeights = src->fPathRef->conicWeightsEnd(); bool needMove = true; bool needClose = false;