CodingMeSwiftly / UIBezierPath-Superpowers

MIT License
78 stars 16 forks source link

Crash when running calculations with zero length path elements. #5

Closed CodingMeSwiftly closed 6 years ago

CodingMeSwiftly commented 6 years ago

It is possible to build a UIBezierPath consisting of "points" rather than actual line elements. In that case point is a zero length line element.

Example:

let p: CGPoint = ...
path.move(to: p)
path.addLine(to: p)

The current implementation does not account for this possibility. Most notably, findPathElement(at:, callback:), which is basically the spine of the library, will search for path elements based on their lengthRange. Things start to burn all over the place when this range is 0...0, which it is for "points".

See https://github.com/ImJCabus/UIBezierPath-Superpowers/issues/1