[System.DirectoryServices] Fixed possible resource leak#120899
Merged
tarekgh merged 5 commits intodotnet:mainfrom Feb 16, 2026
Merged
[System.DirectoryServices] Fixed possible resource leak#120899tarekgh merged 5 commits intodotnet:mainfrom
tarekgh merged 5 commits intodotnet:mainfrom
Conversation
This was referenced Oct 20, 2025
It is worth explicitly calling Dispose for the policyHandle object, since it implements the IDisposable interface.
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request addresses resource leaks in the System.DirectoryServices library by ensuring that SafeLsaPolicyHandle objects are properly disposed. SafeLsaPolicyHandle is a SafeHandle type that wraps an LSA policy handle and must be explicitly disposed to release native resources. The PR was identified by the Linux Verification Center using SVACE static analysis.
Changes:
- Converted simple SafeLsaPolicyHandle usage to
using varpattern in 7 methods for automatic disposal - Added explicit Dispose call in GetTrustedDomainInfo method where handle reassignment occurs
...braries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/TrustHelper.cs
Outdated
Show resolved
Hide resolved
jeffhandley
reviewed
Feb 16, 2026
...braries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/TrustHelper.cs
Show resolved
Hide resolved
jeffhandley
approved these changes
Feb 16, 2026
Member
jeffhandley
left a comment
There was a problem hiding this comment.
Looks good to me. @tarekgh; good with you as well?
Co-authored-by: Copilot <[email protected]>
Member
|
/ba-g the failure is Android specific and not related to the change. |
tarekgh
approved these changes
Feb 16, 2026
Member
|
Thanks @sancheolz for your help with the issue. |
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.
It is worth explicitly calling Dispose for the policyHandle object, since it implements the IDisposable interface.
Found by Linux Verification Center (linuxtesting.org) with SVACE.