mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-27 15:44:00 +08:00
(ZLibStream): dispose of supplied stream in case of initialization errors.
This commit is contained in:
parent
81ab95ebf1
commit
40c280a23c
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion ("1.1.10.423")]
|
||||
[assembly: AssemblyFileVersion ("1.1.10.423")]
|
||||
[assembly: AssemblyVersion ("1.1.10.427")]
|
||||
[assembly: AssemblyFileVersion ("1.1.10.427")]
|
||||
|
@ -78,6 +78,8 @@ namespace GameRes.Compression
|
||||
}
|
||||
|
||||
public ZLibStream (Stream stream, CompressionMode mode, CompressionLevel level, bool leave_open = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (CompressionMode.Decompress == mode)
|
||||
InitDecompress (stream);
|
||||
@ -85,6 +87,13 @@ namespace GameRes.Compression
|
||||
InitCompress (stream, level);
|
||||
m_should_dispose_base = !leave_open;
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (!leave_open)
|
||||
stream.Dispose();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitDecompress (Stream stream)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user