Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix possible NRE in System.Management.ManagementObject.Get(ManagementOperationObserver watcher) - #131261

#131261
Open
sancheolz wants to merge 2 commits into
dotnet:maindotnet/runtime:mainfrom
sancheolz:patch-1sancheolz/runtime:patch-1Copy head branch name to clipboard
Open

Fix possible NRE in System.Management.ManagementObject.Get(ManagementOperationObserver watcher)#131261
sancheolz wants to merge 2 commits into
dotnet:maindotnet/runtime:mainfrom
sancheolz:patch-1sancheolz/runtime:patch-1Copy head branch name to clipboard

Conversation

@sancheolz

@sancheolz sancheolz commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Value sink, which is result of method invocation with possible null return value, is dereferenced in member access expression sink.Stub.

It may throw an NRE, as GetNewGetSink may return null at line 919 in ManagementOperationWatcher.cs. https://github.com/sancheolz/runtime/blob/2adc1e07268539ac8be8ad775b2972e91528ebb0/src/libraries/System.Management/src/System/Management/ManagementOperationWatcher.cs#L297

Found by Linux Verification Center (linuxtesting.org) with SVACE.

…OperationObserver watcher) in

Value sink, which is result of method invocation with possible null return value, is dereferenced in member access expression sink.Stub.
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Jul 23, 2026
@azure-pipelines

Copy link
Copy Markdown
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.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-management
See info in area-owners.md if you want to be subscribed.

Comment on lines +907 to +908
if (sink == null)
throw new InvalidOperationException("Unable to get WmiGetEventSink");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is not the correct fix. GetNewGetSink can only return null by swallowing an exception. If we want to throw, we should let the orignal exception throw.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should I remove try/catch from GetNewGetSink then?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

System.Management hasn't enabled nullable analysis, and there are plenty of code quality issues. It's not suggested to address individual warning like this unless the area owner explicitly requires.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Management community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.