Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix NRE in GenericLookupResult.Equals method #114624

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

Merged

Conversation

Alex4414
Copy link
Contributor

There is a typo in the GenericLookupResult.Equals method. Instead of checking other for null, the argument obj is checked. If obj is not of GenericLookupResult type, then it will be NRE.

fix-nre-in-GenericLookupResult
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Apr 14, 2025
Copy link
Contributor

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

@@ -81,7 +81,7 @@ public abstract class GenericLookupResult
public sealed override bool Equals(object obj)
{
GenericLookupResult other = obj as GenericLookupResult;
if (obj == null)
if (other == null)
Copy link
Member

Choose a reason for hiding this comment

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

if (obj is not GenericLookupResult other)
    return false;

for latest pattern.

@MichalStrehovsky MichalStrehovsky merged commit 9f7bc7e into dotnet:main Apr 14, 2025
98 checks passed
@jnyrup
Copy link
Contributor

jnyrup commented Apr 15, 2025

@Alex4414 Out of curiosity: How did you spot this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-NativeAOT-coreclr 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.

4 participants