Fix 6 PVS-Studio static analyzer findings#27035
Open
SufficientDaikon wants to merge 2 commits intoPowerShell:masterfrom
Open
Fix 6 PVS-Studio static analyzer findings#27035SufficientDaikon wants to merge 2 commits intoPowerShell:masterfrom
SufficientDaikon wants to merge 2 commits intoPowerShell:masterfrom
Conversation
Address items 1, 2, 5, 6, 7, 9 from the PVS-Studio report in PowerShell#25289: - Item 9: Fix ?? operator precedence in StringUtil.cs — appendStr length was silently ignored in capacity calculation - Item 2: Add volatile to logInitialized in CimCmdlets/Utils.cs for safe double-checked locking - Item 6: Move RunspaceRef null check before first use in ConsoleHost.cs to prevent NullReferenceException - Item 1: Add null guard for GetCimInstanceParameter return value in CimGetInstance.cs - Item 5: Use null-conditional on Members["Module"] access in ShowCommandCommandInfo.cs - Item 7: Split vd null check from type check in typeDataQuery.cs to prevent NullReferenceException in trace logging Items 3, 4, 8, 10 are intentionally left — they require design decisions, affect auto-generated code, or would be breaking changes. Addresses PowerShell#25289 Co-Authored-By: Claude Opus 4.6 <[email protected]>
5 tasks
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.
Summary
Fixes 6 of the 10 PVS-Studio static analyzer findings reported in #25289. The remaining 4 items require design decisions, affect auto-generated code, or would be breaking changes — rationale below.
What Changed
StringUtil.cs??precedence —appendStrlength silently ignoredCimCmdlets/Utils.csvolatileConsoleHost.csRunspaceRefused before null checkCimGetInstance.csGetCimInstanceParametercan return nullShowCommandCommandInfo.csMembers["Module"]without null-conditional?.typeDataQuery.csvd.mainControlaccessed whenvd == nullItems NOT Fixed
Intentionally left for maintainer guidance:
GetEventCommand.cssuppressOpenerhas no format placeholders — may be intentional designNew-Object.csFullLanguageswitch case — may be deliberate fall-throughxmlSerializer.autogen.csCommand.csPipelineResultTypesFlags enum — changing values is a breaking changeTests
NullReferenceExceptioncrashes or silent miscalculation under specific conditions.Before / After for each item (click to expand)
Item 9 — Operator precedence
Item 2 — Missing volatile
Item 6 — Null check order
Item 1 — Null dereference
Item 5 — Null access
Item 7 — Null dereference in trace
Related
PR Checklist