mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-04 05:25:00 +00:00
[PR #1161] Fix ArrayPool corruption from double-disposal in BufferedSubStream #1599
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?
Original Pull Request: https://github.com/adamhathcock/sharpcompress/pull/1161
State: closed
Merged: Yes
BufferedSubStream.Disposereturns a rented array toArrayPoolbut lacks guard against multiple disposals. Since_cachewasreadonly, it couldn't be nulled after return, causing the same array to be returned twice on subsequentDisposecalls—corrupting the pool.Changes
_isDisposedflag prevents re-execution of disposal logic_cachenullable: Changed fromreadonly byte[]tobyte[]?to enable nulling after pool returnRefillCachemethods throwObjectDisposedExceptionif called post-disposalCanSeekbefore accessingPositionto avoid exceptions on non-seekable streamsPattern
Follows the same disposal pattern as base class
SharpCompressStream:✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.