[PR #1162] [MERGED] release to master #1598

Open
opened 2026-01-29 22:21:18 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/adamhathcock/sharpcompress/pull/1162
Author: @adamhathcock
Created: 1/26/2026
Status: Merged
Merged: 1/26/2026
Merged by: @adamhathcock

Base: masterHead: adam/release-to-master


📝 Commits (10+)

  • d74454f Merge pull request #1145 from adamhathcock/copilot/add-leaveopen-parameter-lzipstream
  • 97879f1 Merge pull request #1146 from adamhathcock/adam/pr-1145-release
  • 7732fbb Merge pull request #1151 from adamhathcock/copilot/fix-entrystream-flush-issue
  • 21ce9a3 fix up tests
  • d5a8c37 Merge pull request #1154 from adamhathcock/adam/1151-release
  • bf4217f Merge pull request #1156 from adamhathcock/copilot/fix-sharpcompress-archive-iteration
  • 9caf7be Revert testing
  • 4ca1a77 Merge pull request #1157 from adamhathcock/adam/1154-release
  • 44e4b18 add check to see if we need to seek before hand
  • a82fda9 more testing and add pooling to cache

📊 Changes

3 files changed (+70 additions, -12 deletions)

View changed files

📝 src/SharpCompress/IO/BufferedSubStream.cs (+40 -10)
📝 src/SharpCompress/IO/SharpCompressStream.cs (+0 -1)
📝 tests/SharpCompress.Test/Streams/SharpCompressStreamTest.cs (+30 -1)

📄 Description

This pull request improves the safety and robustness of the BufferedSubStream implementation in SharpCompress, particularly around resource management and stream disposal. The changes ensure that the underlying buffer is managed correctly, prevent double disposal issues, and add a new test to verify this behavior. Additionally, minor code improvements and test enhancements are included.

Resource management and disposal safety

  • Added an _isDisposed flag to BufferedSubStream to prevent double disposal and ensure the buffer is only returned to the pool once, avoiding pool corruption. The buffer (_cache) is now set to null after being returned. ([src/SharpCompress/IO/BufferedSubStream.csL32-R50](diffhunk://#diff-e05b040e70e38b0d116d8d268e407131b5ba8b6614af841bc9188cd7f368fee3L32-R50))
  • Updated all usages of _cache to use null-forgiving operator (_cache!) and added checks for _isDisposed in methods that access the buffer, throwing ObjectDisposedException if accessed after disposal. ([[1]](diffhunk://#diff-e05b040e70e38b0d116d8d268e407131b5ba8b6614af841bc9188cd7f368fee3L64-R116), [[2]](diffhunk://#diff-e05b040e70e38b0d116d8d268e407131b5ba8b6614af841bc9188cd7f368fee3L109-R139), [[3]](diffhunk://#diff-e05b040e70e38b0d116d8d268e407131b5ba8b6614af841bc9188cd7f368fee3L127-R157), [[4]](diffhunk://#diff-e05b040e70e38b0d116d8d268e407131b5ba8b6614af841bc9188cd7f368fee3L150-R180), [[5]](diffhunk://#diff-e05b040e70e38b0d116d8d268e407131b5ba8b6614af841bc9188cd7f368fee3L177-R207))

Test improvements

  • Added a new unit test BufferedSubStream_DoubleDispose_DoesNotCorruptArrayPool to verify that double disposal does not corrupt the array pool or throw exceptions. ([tests/SharpCompress.Test/Streams/SharpCompressStreamTest.csR100-R120](diffhunk://#diff-5203913d939d601de98a07fe1ef8384114c7cbb9de17ccc5a93297b51c301e6eR100-R120))
  • Modified the existing test to use a ForwardOnlyStream wrapper for more accurate stream behavior simulation. ([tests/SharpCompress.Test/Streams/SharpCompressStreamTest.csL67-R75](diffhunk://#diff-5203913d939d601de98a07fe1ef8384114c7cbb9de17ccc5a93297b51c301e6eL67-R75))
  • Added missing test mock import for completeness. ([tests/SharpCompress.Test/Streams/SharpCompressStreamTest.csR8](diffhunk://#diff-5203913d939d601de98a07fe1ef8384114c7cbb9de17ccc5a93297b51c301e6eR8))

Minor codebase cleanups

  • Removed an unused variable (orig) from the Seek method in SharpCompressStream. ([src/SharpCompress/IO/SharpCompressStream.csL258](diffhunk://#diff-d90e17bbeae23cfc33ba23708baa5342f5eb76666ee072503791fee3432a1c04L258))

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/adamhathcock/sharpcompress/pull/1162 **Author:** [@adamhathcock](https://github.com/adamhathcock) **Created:** 1/26/2026 **Status:** ✅ Merged **Merged:** 1/26/2026 **Merged by:** [@adamhathcock](https://github.com/adamhathcock) **Base:** `master` ← **Head:** `adam/release-to-master` --- ### 📝 Commits (10+) - [`d74454f`](https://github.com/adamhathcock/sharpcompress/commit/d74454f7e9a19c9434c6277964c1e2e1f7b01f0a) Merge pull request #1145 from adamhathcock/copilot/add-leaveopen-parameter-lzipstream - [`97879f1`](https://github.com/adamhathcock/sharpcompress/commit/97879f18b61fe109205e23f23fc2708479b31eec) Merge pull request #1146 from adamhathcock/adam/pr-1145-release - [`7732fbb`](https://github.com/adamhathcock/sharpcompress/commit/7732fbb698b988aaf1edb7c729521930bd176253) Merge pull request #1151 from adamhathcock/copilot/fix-entrystream-flush-issue - [`21ce9a3`](https://github.com/adamhathcock/sharpcompress/commit/21ce9a38e64c279b04a75c5ec6570fc495bb457e) fix up tests - [`d5a8c37`](https://github.com/adamhathcock/sharpcompress/commit/d5a8c37113ea15cc209a2eba7f142cd88b54ffd5) Merge pull request #1154 from adamhathcock/adam/1151-release - [`bf4217f`](https://github.com/adamhathcock/sharpcompress/commit/bf4217fde6005373ce5ade86ca3549fb73c93f00) Merge pull request #1156 from adamhathcock/copilot/fix-sharpcompress-archive-iteration - [`9caf7be`](https://github.com/adamhathcock/sharpcompress/commit/9caf7be928d908ff37959bf9a01c74d68f215c13) Revert testing - [`4ca1a77`](https://github.com/adamhathcock/sharpcompress/commit/4ca1a7713ec8639260fbfa8c11ebbb16bc3ac90c) Merge pull request #1157 from adamhathcock/adam/1154-release - [`44e4b18`](https://github.com/adamhathcock/sharpcompress/commit/44e4b1804ec2c64f865eca8547c5c81879a82282) add check to see if we need to seek before hand - [`a82fda9`](https://github.com/adamhathcock/sharpcompress/commit/a82fda98d789a708f8429fbc6b8acbebd8ea3823) more testing and add pooling to cache ### 📊 Changes **3 files changed** (+70 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `src/SharpCompress/IO/BufferedSubStream.cs` (+40 -10) 📝 `src/SharpCompress/IO/SharpCompressStream.cs` (+0 -1) 📝 `tests/SharpCompress.Test/Streams/SharpCompressStreamTest.cs` (+30 -1) </details> ### 📄 Description This pull request improves the safety and robustness of the `BufferedSubStream` implementation in `SharpCompress`, particularly around resource management and stream disposal. The changes ensure that the underlying buffer is managed correctly, prevent double disposal issues, and add a new test to verify this behavior. Additionally, minor code improvements and test enhancements are included. ### Resource management and disposal safety * Added an `_isDisposed` flag to `BufferedSubStream` to prevent double disposal and ensure the buffer is only returned to the pool once, avoiding pool corruption. The buffer (`_cache`) is now set to `null` after being returned. (`[src/SharpCompress/IO/BufferedSubStream.csL32-R50](diffhunk://#diff-e05b040e70e38b0d116d8d268e407131b5ba8b6614af841bc9188cd7f368fee3L32-R50)`) * Updated all usages of `_cache` to use null-forgiving operator (`_cache!`) and added checks for `_isDisposed` in methods that access the buffer, throwing `ObjectDisposedException` if accessed after disposal. (`[[1]](diffhunk://#diff-e05b040e70e38b0d116d8d268e407131b5ba8b6614af841bc9188cd7f368fee3L64-R116)`, `[[2]](diffhunk://#diff-e05b040e70e38b0d116d8d268e407131b5ba8b6614af841bc9188cd7f368fee3L109-R139)`, `[[3]](diffhunk://#diff-e05b040e70e38b0d116d8d268e407131b5ba8b6614af841bc9188cd7f368fee3L127-R157)`, `[[4]](diffhunk://#diff-e05b040e70e38b0d116d8d268e407131b5ba8b6614af841bc9188cd7f368fee3L150-R180)`, `[[5]](diffhunk://#diff-e05b040e70e38b0d116d8d268e407131b5ba8b6614af841bc9188cd7f368fee3L177-R207)`) ### Test improvements * Added a new unit test `BufferedSubStream_DoubleDispose_DoesNotCorruptArrayPool` to verify that double disposal does not corrupt the array pool or throw exceptions. (`[tests/SharpCompress.Test/Streams/SharpCompressStreamTest.csR100-R120](diffhunk://#diff-5203913d939d601de98a07fe1ef8384114c7cbb9de17ccc5a93297b51c301e6eR100-R120)`) * Modified the existing test to use a `ForwardOnlyStream` wrapper for more accurate stream behavior simulation. (`[tests/SharpCompress.Test/Streams/SharpCompressStreamTest.csL67-R75](diffhunk://#diff-5203913d939d601de98a07fe1ef8384114c7cbb9de17ccc5a93297b51c301e6eL67-R75)`) * Added missing test mock import for completeness. (`[tests/SharpCompress.Test/Streams/SharpCompressStreamTest.csR8](diffhunk://#diff-5203913d939d601de98a07fe1ef8384114c7cbb9de17ccc5a93297b51c301e6eR8)`) ### Minor codebase cleanups * Removed an unused variable (`orig`) from the `Seek` method in `SharpCompressStream`. (`[src/SharpCompress/IO/SharpCompressStream.csL258](diffhunk://#diff-d90e17bbeae23cfc33ba23708baa5342f5eb76666ee072503791fee3432a1c04L258)`) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 22:21:18 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#1598