diff --git a/src/UglyToad.PdfPig/Graphics/ContentStreamProcessor.cs b/src/UglyToad.PdfPig/Graphics/ContentStreamProcessor.cs index 4bfe7381..eff2248c 100644 --- a/src/UglyToad.PdfPig/Graphics/ContentStreamProcessor.cs +++ b/src/UglyToad.PdfPig/Graphics/ContentStreamProcessor.cs @@ -458,7 +458,7 @@ if (close) { - CurrentSubpath.CloseSubpath(); + CurrentSubpath?.CloseSubpath(); } ClosePath(); @@ -475,7 +475,7 @@ if (close) { - CurrentSubpath.CloseSubpath(); + CurrentSubpath?.CloseSubpath(); } ClosePath(); @@ -493,7 +493,7 @@ if (close) { - CurrentSubpath.CloseSubpath(); + CurrentSubpath?.CloseSubpath(); } ClosePath(); @@ -501,6 +501,11 @@ public void EndPath() { + if (CurrentPath == null) + { + return; + } + AddCurrentSubpath(); if (CurrentPath.IsClipping)