diff --git a/binding/Binding/SKDocument.cs b/binding/Binding/SKDocument.cs index f05565b4..8479876b 100644 --- a/binding/Binding/SKDocument.cs +++ b/binding/Binding/SKDocument.cs @@ -63,7 +63,10 @@ namespace SkiaSharp var stream = SKFileWStream.OpenStream (path); var doc = CreateXps (stream, dpi); - doc.SetDisposeChild (stream); + if (doc != null) + doc.SetDisposeChild (stream); + else + stream.Dispose(); return doc; } @@ -85,7 +88,10 @@ namespace SkiaSharp var stream = SKFileWStream.OpenStream (path); var doc = CreatePdf (stream, dpi); - doc.SetDisposeChild (stream); + if (doc != null) + doc.SetDisposeChild (stream); + else + stream.Dispose(); return doc; }