Repository navigation
Fix pooled buffer ownership and exception-safe cleanup - #1447
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
LZMA2 construction can leak a rented buffer, and writes remain possible after that buffer is returned.
1 open finding
What changed in this PR
Improves pooled-buffer ownership and exception-safe cleanup across LZMA, RAR, and Tar paths.
Changes:
- Makes buffer replacement and disposal safer.
- Adds injectable pools and 14 regression cases.
- Documents
CrcCheckStreamdisposal behavior.
| File | Description |
|---|---|
tests/SharpCompress.Test/Streams/BufferPoolLifetimeTests.cs |
Adds buffer-lifetime regressions. |
src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.cs |
Safely replaces sync filter buffers. |
src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.Async.cs |
Safely replaces async filter buffers. |
src/SharpCompress/Compressors/LZMA/Utilities/CrcCheckStream.cs |
Makes disposal idempotent and rejects writes afterward. |
src/SharpCompress/Compressors/LZMA/LzmaEncoder.cs |
Safely replaces literal models. |
src/SharpCompress/Compressors/LZMA/Lzma2EncoderStream.cs |
Releases encoder buffers after output failures. |
src/SharpCompress/Compressors/LZMA/LZ/LzOutWindow.cs |
Adds injectable pooling and safe replacement. |
src/SharpCompress/Compressors/LZMA/LZ/LzOutWindow.Async.cs |
Uses the injected pool during async cleanup. |
src/SharpCompress/Compressors/LZMA/LZ/LzBinTree.cs |
Safely replaces match-finder buffers. |
src/SharpCompress/Common/Tar/Headers/TarHeader.Async.cs |
Adds pool injection for lifetime tests. |
docs/API.md |
Documents CRC stream disposal semantics. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This was referenced Oct 19, 2026
Closed
This was referenced Nov 16, 2026
Closed
This was referenced Nov 23, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Validation
dotnet csharpier format .,dotnet csharpier check ., andgit diff --checkcompleted successfully.Based on the latest origin/release; follows up on b924008.