(OpenImage): dispose input on exception.

This commit is contained in:
morkt 2016-12-23 00:54:30 +04:00
parent 34012bcdd0
commit 1ac0931d62
2 changed files with 18 additions and 2 deletions

View File

@ -67,8 +67,16 @@ namespace GameRes
public virtual IImageDecoder OpenImage (ArcFile arc, Entry entry)
{
var input = arc.OpenBinaryEntry (entry);
try
{
return new ImageFormatDecoder (input);
}
catch
{
input.Dispose();
throw;
}
}
/// <summary>
/// Create file corresponding to <paramref name="entry"/> in current directory and open it

View File

@ -730,8 +730,16 @@ namespace GameRes
return arc_fs.Source.OpenImage (entry);
var input = fs.OpenBinaryStream (entry);
try
{
return new ImageFormatDecoder (input);
}
catch
{
input.Dispose();
throw;
}
}
public static Stream OpenStream (string filename)
{