Skip to content

Commit

Permalink
Handle special case where path consists of a single move command
Browse files Browse the repository at this point in the history
- prevents crash, fixes #223
  • Loading branch information
mrbean-bremen committed Feb 3, 2019
1 parent c409d2e commit f7c5fb0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Source/Paths/SvgPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,27 @@ public override GraphicsPath Path(ISvgRenderer renderer)
{
if (this._path == null || this.IsPathDirty)
{
_path = new GraphicsPath();
this._path = new GraphicsPath();

foreach (SvgPathSegment segment in this.PathData)
{
segment.AddToPath(_path);
}

if (_path.PointCount == 0)
{
if (this.PathData.Count > 0)
{
// special case with one move command only, see #223
var segment = this.PathData.Last;
_path.AddLine(segment.End, segment.End);
this.Fill = SvgPaintServer.None;
}
else
{
_path = null;
}
}
this.IsPathDirty = false;
}
return _path;
Expand Down
2 changes: 2 additions & 0 deletions Tests/Svg.UnitTests/PassingTests.csv
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ __issue-191-01
__issue-202-01
__issue-214-01
__issue-215-01
__issue-223-01
__issue-223-02
__issue-227-01
__issue-227-02
__issue-239-01
Expand Down
Binary file modified Tests/W3CTestSuite/png/__issue-223-01.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Tests/W3CTestSuite/png/__issue-223-02.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f7c5fb0

Please sign in to comment.