fix: Stream dispose

This commit is contained in:
Crsky
2026-04-02 05:49:46 +08:00
parent ea358185a6
commit 0bed7317e7

View File

@@ -267,6 +267,8 @@ namespace GameRes.Formats.NeXAS
if (null == pac) if (null == pac)
return input; return input;
if (Compression.NeedDecryptionOnly == pac.PackType) if (Compression.NeedDecryptionOnly == pac.PackType)
{
using (input)
{ {
var data = new byte[entry.Size]; var data = new byte[entry.Size];
input.Read (data, 0, data.Length); input.Read (data, 0, data.Length);
@@ -274,6 +276,7 @@ namespace GameRes.Formats.NeXAS
data[i] = (byte)~data[i]; data[i] = (byte)~data[i];
return new BinMemoryStream (data, entry.Name); return new BinMemoryStream (data, entry.Name);
} }
}
if (null == pent || !pent.IsPacked) if (null == pent || !pent.IsPacked)
return input; return input;
@@ -295,10 +298,13 @@ namespace GameRes.Formats.NeXAS
return new ZLibStream (input, CompressionMode.Decompress); return new ZLibStream (input, CompressionMode.Decompress);
case Compression.Zstd: case Compression.Zstd:
case Compression.ZstdOrNone: case Compression.ZstdOrNone:
{
using (input)
{ {
var unpacked = ZstdDecompress (input, pent.UnpackedSize); var unpacked = ZstdDecompress (input, pent.UnpackedSize);
return new BinMemoryStream (unpacked, entry.Name); return new BinMemoryStream (unpacked, entry.Name);
} }
}
default: default:
return input; return input;
} }