Skip to content

Commit

Permalink
add null check around assembly & location (#3606)
Browse files Browse the repository at this point in the history
* add null check around assembly & location

* Add PathIsValid check

* fmt
  • Loading branch information
adamhathcock authored Jul 31, 2024
1 parent fdddfd7 commit b65c3fa
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions ConnectorCore/DllConflictManagement/DllConflictManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,37 @@ HashSet<string> visitedAssemblies
}
}

private bool ShouldSkipCheckingConflictBecauseOfAssemblyLocation(Assembly loadedAssembly)
private static bool PathIsValid(string path)
{
if (path.Any(x => Path.GetInvalidPathChars().Contains(x)))
{
return false;
}
return true;
}

private bool ShouldSkipCheckingConflictBecauseOfAssemblyLocation(Assembly? loadedAssembly)
{
if (string.IsNullOrWhiteSpace(loadedAssembly?.Location))
{
return false;
}
string location = loadedAssembly!.Location;
if (!PathIsValid(location))
{
return false;
}
foreach (var exactPath in _exactAssemblyPathsToIgnore)
{
if (Path.GetDirectoryName(loadedAssembly.Location) == exactPath)
if (Path.GetDirectoryName(location) == exactPath)
{
return true;
}
}

foreach (var pathFragment in _assemblyPathFragmentsToIgnore)
{
if (loadedAssembly.Location.Contains(pathFragment))
if (location.Contains(pathFragment))
{
return true;
}
Expand Down

0 comments on commit b65c3fa

Please sign in to comment.