mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-04 05:25:00 +00:00
[PR #1162] [MERGED] release to master #1598
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 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:
master← Head:adam/release-to-master📝 Commits (10+)
d74454fMerge pull request #1145 from adamhathcock/copilot/add-leaveopen-parameter-lzipstream97879f1Merge pull request #1146 from adamhathcock/adam/pr-1145-release7732fbbMerge pull request #1151 from adamhathcock/copilot/fix-entrystream-flush-issue21ce9a3fix up testsd5a8c37Merge pull request #1154 from adamhathcock/adam/1151-releasebf4217fMerge pull request #1156 from adamhathcock/copilot/fix-sharpcompress-archive-iteration9caf7beRevert testing4ca1a77Merge pull request #1157 from adamhathcock/adam/1154-release44e4b18add check to see if we need to seek before handa82fda9more 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
BufferedSubStreamimplementation inSharpCompress, 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
_isDisposedflag toBufferedSubStreamto prevent double disposal and ensure the buffer is only returned to the pool once, avoiding pool corruption. The buffer (_cache) is now set tonullafter being returned. ([src/SharpCompress/IO/BufferedSubStream.csL32-R50](diffhunk://#diff-e05b040e70e38b0d116d8d268e407131b5ba8b6614af841bc9188cd7f368fee3L32-R50))_cacheto use null-forgiving operator (_cache!) and added checks for_isDisposedin methods that access the buffer, throwingObjectDisposedExceptionif 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
BufferedSubStream_DoubleDispose_DoesNotCorruptArrayPoolto verify that double disposal does not corrupt the array pool or throw exceptions. ([tests/SharpCompress.Test/Streams/SharpCompressStreamTest.csR100-R120](diffhunk://#diff-5203913d939d601de98a07fe1ef8384114c7cbb9de17ccc5a93297b51c301e6eR100-R120))ForwardOnlyStreamwrapper for more accurate stream behavior simulation. ([tests/SharpCompress.Test/Streams/SharpCompressStreamTest.csL67-R75](diffhunk://#diff-5203913d939d601de98a07fe1ef8384114c7cbb9de17ccc5a93297b51c301e6eL67-R75))[tests/SharpCompress.Test/Streams/SharpCompressStreamTest.csR8](diffhunk://#diff-5203913d939d601de98a07fe1ef8384114c7cbb9de17ccc5a93297b51c301e6eR8))Minor codebase cleanups
orig) from theSeekmethod inSharpCompressStream. ([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.