fix: Stream dispose

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

View File

@@ -268,11 +268,14 @@ namespace GameRes.Formats.NeXAS
return input; return input;
if (Compression.NeedDecryptionOnly == pac.PackType) if (Compression.NeedDecryptionOnly == pac.PackType)
{ {
var data = new byte[entry.Size]; using (input)
input.Read (data, 0, data.Length); {
for (int i = 0; i < Math.Min (3, data.Length); i++) var data = new byte[entry.Size];
data[i] = (byte)~data[i]; input.Read (data, 0, data.Length);
return new BinMemoryStream (data, entry.Name); for (int i = 0; i < Math.Min (3, data.Length); i++)
data[i] = (byte)~data[i];
return new BinMemoryStream (data, entry.Name);
}
} }
if (null == pent || !pent.IsPacked) if (null == pent || !pent.IsPacked)
return input; return input;
@@ -296,8 +299,11 @@ namespace GameRes.Formats.NeXAS
case Compression.Zstd: case Compression.Zstd:
case Compression.ZstdOrNone: case Compression.ZstdOrNone:
{ {
var unpacked = ZstdDecompress (input, pent.UnpackedSize); using (input)
return new BinMemoryStream (unpacked, entry.Name); {
var unpacked = ZstdDecompress (input, pent.UnpackedSize);
return new BinMemoryStream (unpacked, entry.Name);
}
} }
default: default:
return input; return input;