Skip to content

Improve pointer lifecycle handling in PdhHelper - #28008

Merged
Patrick Meinecke (SeeminglyScience) merged 3 commits into
PowerShell:masterfrom
anamnavi:pdhhelper-validation
Sep 11, 2026
Merged

Patrick Meinecke (SeeminglyScience) merged 3 commits into
PowerShell:masterfrom
anamnavi:pdhhelper-validation

Conversation

@anamnavi

@anamnavi Anam Navied (anamnavi) commented Sep 11, 2026

Copy link
Copy Markdown
Member

PR Summary

This pull request improves pointer handling in the LookupPerfNameByIndex method in PdhHelper.cs. When additional buffer space is required, the existing allocation is freed before a new allocation is created. This change explicitly resets the pointer to IntPtr.Zero after the free operation, ensuring the pointer state remains accurate throughout the reallocation flow.

PR Context

PR Checklist

Copilot AI lite review requested due to automatic review settings September 11, 2026 17:30
@anamnavi
Anam Navied (anamnavi) requested a review from a team as a code owner September 11, 2026 17:30
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No unresolved review issues remain.

Pull request overview

This pull request improves unmanaged pointer lifecycle handling in PdhHelper during buffer reallocation.

Changes:

  • Resets the freed pointer to IntPtr.Zero before reallocation.
  • Prevents stale-pointer cleanup if allocation fails.
File summaries
File Description
src/Microsoft.PowerShell.Commands.Diagnostics/PdhHelper.cs Safeguards pointer cleanup during PDH_MORE_DATA handling.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@TravisEz13 Travis Plunk (TravisEz13) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Sep 11, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@anamnavi

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Commenter does not have sufficient privileges for PR 28008 in repo PowerShell/PowerShell

@SeeminglyScience
Patrick Meinecke (SeeminglyScience) merged commit 5e35e5a into PowerShell:master Sep 11, 2026
44 of 46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants