Commit ac316146 authored by mrbean-bremen's avatar mrbean-bremen
Browse files

Prevent crashes on zero length segments or paths

- fixes __tiger.svg test image
parent f9181931
......@@ -8,10 +8,15 @@ namespace Svg.Pathing
{
public override void AddToPath(System.Drawing.Drawing2D.GraphicsPath graphicsPath)
{
if (graphicsPath.PointCount == 0)
{
return;
}
// Important for custom line caps. Force the path the close with an explicit line, not just an implicit close of the figure.
var pathPoints = graphicsPath.PathPoints;
if (pathPoints.Length > 0 && !pathPoints[0].Equals(pathPoints[pathPoints.Length - 1]))
if (!pathPoints[0].Equals(pathPoints[pathPoints.Length - 1]))
{
var pathTypes = graphicsPath.PathTypes;
int i = pathPoints.Length - 1;
......
......@@ -15,7 +15,10 @@ namespace Svg.Pathing
public override void AddToPath(System.Drawing.Drawing2D.GraphicsPath graphicsPath)
{
graphicsPath.AddLine(this.Start, this.End);
if (this.Start != this.End)
{
graphicsPath.AddLine(this.Start, this.End);
}
}
public override string ToString()
......
......@@ -15,7 +15,10 @@ namespace Svg.Pathing
public override void AddToPath(System.Drawing.Drawing2D.GraphicsPath graphicsPath)
{
graphicsPath.StartFigure();
if (this.Start != this.End)
{
graphicsPath.StartFigure();
}
}
public override string ToString()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment