Fix dispose state checks - #131647
Draft
alinpahontu2912 wants to merge 1 commit into
Draft
Conversation
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @karelz, @dotnet/area-system-io-compression |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts disposal-state handling in System.IO.Compression to ensure disposed objects consistently trip ObjectDisposedException checks, including in async disposal paths and in the Zstandard decoder’s early-return logic.
Changes:
ZstandardDecoder.Decompress: move the disposed-state check to occur before returningOperationStatus.Donewhen_finishedis already true.WinZipAesStream.DisposeAsync: set_disposed = trueinside thefinallyblock to ensure it’s set even when disposal/finalization steps throw.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/libraries/System.IO.Compression/src/System/IO/Compression/Zstandard/ZstandardDecoder.cs | Ensures Decompress validates disposed state even on the _finished fast path. |
| src/libraries/System.IO.Compression/src/System/IO/Compression/WinZipAesStream.cs | Ensures async disposal always marks the stream disposed by setting _disposed in finally. |
Comment on lines
171
to
176
| bytesWritten = 0; | ||
| bytesConsumed = 0; | ||
|
|
||
| EnsureNotDisposed(); | ||
|
|
||
| if (_finished) |
alinpahontu2912
marked this pull request as draft
July 31, 2026 14:35
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.
Fix dispose state checks for async Winzipaesstream and zstandarddecoder