Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ImportedProjects
SVG
Commits
8ad92e3a
Commit
8ad92e3a
authored
Mar 12, 2017
by
Tebjan Halm
Committed by
GitHub
Mar 12, 2017
Browse files
Merge pull request #294 from mrbean-bremen/empty-path-crash
Prevent crashes on zero length segments or paths
parents
2a4bc179
ac316146
Changes
3
Hide whitespace changes
Inline
Side-by-side
Source/Paths/SvgClosePathSegment.cs
View file @
8ad92e3a
...
@@ -8,10 +8,15 @@ namespace Svg.Pathing
...
@@ -8,10 +8,15 @@ namespace Svg.Pathing
{
{
public
override
void
AddToPath
(
System
.
Drawing
.
Drawing2D
.
GraphicsPath
graphicsPath
)
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.
// 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
;
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
;
var
pathTypes
=
graphicsPath
.
PathTypes
;
int
i
=
pathPoints
.
Length
-
1
;
int
i
=
pathPoints
.
Length
-
1
;
...
...
Source/Paths/SvgLineSegment.cs
View file @
8ad92e3a
...
@@ -15,7 +15,10 @@ namespace Svg.Pathing
...
@@ -15,7 +15,10 @@ namespace Svg.Pathing
public
override
void
AddToPath
(
System
.
Drawing
.
Drawing2D
.
GraphicsPath
graphicsPath
)
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
()
public
override
string
ToString
()
...
...
Source/Paths/SvgMoveToSegment.cs
View file @
8ad92e3a
...
@@ -15,7 +15,10 @@ namespace Svg.Pathing
...
@@ -15,7 +15,10 @@ namespace Svg.Pathing
public
override
void
AddToPath
(
System
.
Drawing
.
Drawing2D
.
GraphicsPath
graphicsPath
)
public
override
void
AddToPath
(
System
.
Drawing
.
Drawing2D
.
GraphicsPath
graphicsPath
)
{
{
graphicsPath
.
StartFigure
();
if
(
this
.
Start
!=
this
.
End
)
{
graphicsPath
.
StartFigure
();
}
}
}
public
override
string
ToString
()
public
override
string
ToString
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment