Skip to content

Fix potential null pCommonAssemImport handling in ImportTypeRef#126151

Open
tpa95 wants to merge 3 commits intodotnet:mainfrom
tpa95:fix/coreclr_null_deref
Open

Fix potential null pCommonAssemImport handling in ImportTypeRef#126151
tpa95 wants to merge 3 commits intodotnet:mainfrom
tpa95:fix/coreclr_null_deref

Conversation

@tpa95
Copy link
Contributor

@tpa95 tpa95 commented Mar 26, 2026

Static analysis reported that pCommonAssemImport may be null on a path that reaches CreateAssemblyRefFromAssembly, where it is dereferenced. Add a null check before using pCommonAssemImport to avoid dereferencing a null assembly import interface.

Found by Linux Verification Center (linuxtesting.org) with SVACE.
Reporter: Pavel Tikhomirov (Tihomirov-P@gaz-is.ru).
Organization: Gazinformservice (resp@gaz-is.ru).

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Mar 26, 2026
@dotnet-policy-service
Copy link
Contributor

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

&tkOuterEmitRes));
}
else if (TypeFromToken(tkImplementation) == mdtAssemblyRef)
if (pCommonAssemImport != NULL)
Copy link
Member

Choose a reason for hiding this comment

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

The other invariants in the code should guarantee that this is never null.

If this was ever null, it is better to crash or return error rather than silently misbehaving.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jkotas Thanks for the review. Just to make sure I understand the expected direction: would you prefer to rely on the invariant that pCommonAssemImport is never null here, or to handle a null value explicitly with an assert/error path rather than a silent check?

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

Labels

area-AssemblyLoader-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.

2 participants