Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NullReferenceException when the native enumerator returns null #620

Merged
merged 5 commits into from
Oct 12, 2023

Conversation

GeertvanHorrik
Copy link
Member

Fixes a NullReferenceException when the native enumerator returns null.

using System.Threading;

public static class IWbemClassObjectEnumeratorExtensions
{
internal static IWbemClassObject Next(this IWbemClassObjectEnumerator wbemClassObjectEnumerator)
internal static IWbemClassObject? Next(this IWbemClassObjectEnumerator wbemClassObjectEnumerator)
{
const uint count = 1;
var hresult = wbemClassObjectEnumerator.Next(Timeout.Infinite, count, out var current, out _);
Copy link
Contributor

Choose a reason for hiding this comment

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

IWbemClassObjectEnumerator i think it should have nullable notation for parameter: out IWbemClassObject? objects,

@GeertvanHorrik GeertvanHorrik merged commit 405ec99 into develop Oct 12, 2023
1 check passed
@GeertvanHorrik GeertvanHorrik deleted the feature/nullable-fix branch October 12, 2023 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants