diff --git a/GameRes/ArchiveFormat.cs b/GameRes/ArchiveFormat.cs index 4117d495..4bfa0568 100644 --- a/GameRes/ArchiveFormat.cs +++ b/GameRes/ArchiveFormat.cs @@ -67,7 +67,15 @@ namespace GameRes public virtual IImageDecoder OpenImage (ArcFile arc, Entry entry) { var input = arc.OpenBinaryEntry (entry); - return new ImageFormatDecoder (input); + try + { + return new ImageFormatDecoder (input); + } + catch + { + input.Dispose(); + throw; + } } /// diff --git a/GameRes/FileSystem.cs b/GameRes/FileSystem.cs index 9764486a..0ae9c2da 100644 --- a/GameRes/FileSystem.cs +++ b/GameRes/FileSystem.cs @@ -730,7 +730,15 @@ namespace GameRes return arc_fs.Source.OpenImage (entry); var input = fs.OpenBinaryStream (entry); - return new ImageFormatDecoder (input); + try + { + return new ImageFormatDecoder (input); + } + catch + { + input.Dispose(); + throw; + } } public static Stream OpenStream (string filename)