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

False-positive IsNullOrEmpty on StrPtrAuto #455

Closed
sovdchains opened this issue Apr 22, 2024 · 1 comment
Closed

False-positive IsNullOrEmpty on StrPtrAuto #455

sovdchains opened this issue Apr 22, 2024 · 1 comment

Comments

@sovdchains
Copy link

sovdchains commented Apr 22, 2024

Describe the bug and how to reproduce

When subscribing to service creation via AdvApi32.NotifyServiceStatusChange and AdvApi32.SERVICE_NOTIFY_FLAGS.SERVICE_NOTIFY_CREATED the returning structures pszServiceNames contains a false-positive IsNullOrEmpty even though the value is neither null nor empty. The IsNull check is okay, it returns false. But the check for string.Empty returns true, which leads to the false-positive. Checking for IsNull, then retrieving the string and checking the returned string for string.Empty myself gives the desired result.

What code is involved

private void HandleServiceStatusChange(IntPtr pParameter)
{
    AdvApi32.SERVICE_NOTIFY_2 serviceNotify = pParameter.ToStructure<AdvApi32.SERVICE_NOTIFY_2>();

    if (!serviceNotify.pszServiceNames.IsNullOrEmpty)
        Console.WriteLine(serviceNotify.pszServiceNames.ToString());
}

Expected behavior

Returning false on non-empty values.

@dahall
Copy link
Owner

dahall commented Apr 23, 2024

Fixed for 4.0.1

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

No branches or pull requests

2 participants