Skip to content

Fix potential null dereference#125493

Closed
rustamque wants to merge 1 commit intodotnet:mainfrom
rustamque:fix-command-line-null-deref
Closed

Fix potential null dereference#125493
rustamque wants to merge 1 commit intodotnet:mainfrom
rustamque:fix-command-line-null-deref

Conversation

@rustamque
Copy link

Added a fallback to string.Empty for originalPath before calling Path.GetFileName to prevent a potential NullReferenceException.

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

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Mar 12, 2026
string prefix = input ? string.Empty : "out_"; // prefix output directories for clarity
string reproFileDir = prefix + originalToReproPackageFileName.Count.ToString() + Path.DirectorySeparatorChar;
reproPackagePath = Path.Combine(reproFileDir, Path.GetFileName(originalPath));
string fileName = Path.GetFileName(originalPath ?? string.Empty);
Copy link
Member

Choose a reason for hiding this comment

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

originalPath can never be null here, because it's used by Dictionary.TryGetValue above.

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

Labels

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

3 participants