Skip to content

Commit

Permalink
Merge pull request #728 from dotnet/fixNRE
Browse files Browse the repository at this point in the history
Fix NullReferenceException thrown when PATH is empty/missing
  • Loading branch information
AArnott committed Mar 14, 2022
2 parents d66ac53 + be4a5a7 commit ba46f06
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Nerdbank.GitVersioning.Tasks/ContextAwareTask.cs
Expand Up @@ -56,7 +56,7 @@ public override bool Execute()
// On .NET Framework (on Windows), we find native binaries by adding them to our PATH.
if (this.UnmanagedDllDirectory is not null)
{
string pathEnvVar = Environment.GetEnvironmentVariable("PATH");
string pathEnvVar = Environment.GetEnvironmentVariable("PATH") ?? string.Empty;
string[] searchPaths = pathEnvVar.Split(Path.PathSeparator);
if (!searchPaths.Contains(this.UnmanagedDllDirectory, StringComparer.OrdinalIgnoreCase))
{
Expand Down

0 comments on commit ba46f06

Please sign in to comment.