Make raw LZMA setup and disposal exception-safe

This commit is contained in:
Adam Hathcock
2026-10-13 10:29:07 +01:00
parent 38e3222dc2
commit bdb42df4dc
8 changed files with 291 additions and 75 deletions

View File

@@ -836,6 +836,8 @@ using (var reader = ReaderFactory.OpenReader(stream))
`SharpCompressStream` rejects reading and starting recording after disposal. Its pooled ring buffer is released even when disposal of the underlying stream fails.
`LzmaStream` also rejects reads and writes after disposal. Failed initialization releases internal buffers without closing the supplied stream; successful construction retains the specified `leaveOpen` semantics. Disposal releases internal buffers even if finalization or underlying stream disposal throws.
`SharpCompress.Compressors.LZMA.Utilities.CrcCheckStream` validates its expected CRC on disposal. A mismatch throws `ArchiveOperationException`, but pooled buffers are still released. Repeated disposal is safe, including after failed CRC validation. Once disposed, `CanWrite` is `false`, and `Write` / `WriteAsync` throw `ObjectDisposedException`.
## Related Documentation