diff --git a/src/ReleaseHistory.md b/src/ReleaseHistory.md index 38fd2b818..5c6ba6545 100644 --- a/src/ReleaseHistory.md +++ b/src/ReleaseHistory.md @@ -14,6 +14,7 @@ * FEATURE: Allow external set of `MaxFileSizeInKilobytes`, which will allow SDK users to change the value. (Default value is 1024) [#2578](https://github.com/microsoft/sarif-sdk/pull/2578) * FEATURE: Add a Github validation rule `GH1007`, which requires flattened result message so GHAS code scanning can ingest the log. [#2580](https://github.com/microsoft/sarif-sdk/issues/2580) * BUGFIX: MSBuild Converter now accepts case insensitive keywords and supports PackageValidator msbuild log output. [#2579](https://github.com/microsoft/sarif-sdk/pull/2579) +* BUGFIX: Eliminate `NullReferenceException` when file hashing fails (due to file locked or other errors reading the file). [#2596](https://github.com/microsoft/sarif-sdk/pull/2596) ## **v3.1.0** [Sdk](https://www.nuget.org/packages/Sarif.Sdk/3.1.0) | [Driver](https://www.nuget.org/packages/Sarif.Driver/3.1.0) | [Converters](https://www.nuget.org/packages/Sarif.Converters/3.1.0) | [Multitool](https://www.nuget.org/packages/Sarif.Multitool/3.1.0) | [Multitool Library](https://www.nuget.org/packages/Sarif.Multitool.Library/3.1.0) diff --git a/src/Sarif.Driver/Sdk/MultithreadedAnalyzeCommandBase.cs b/src/Sarif.Driver/Sdk/MultithreadedAnalyzeCommandBase.cs index 3311b4b5b..db75cd351 100644 --- a/src/Sarif.Driver/Sdk/MultithreadedAnalyzeCommandBase.cs +++ b/src/Sarif.Driver/Sdk/MultithreadedAnalyzeCommandBase.cs @@ -513,11 +513,12 @@ private async Task HashFilesAndPutInAnalysisQueueAsnc() loggerCache ??= new Dictionary(); - if (!loggerCache.TryGetValue(hashData.Sha256, out CachingLogger logger)) + if (hashData?.Sha256 != null) { - logger = loggerCache[hashData.Sha256] = (CachingLogger)context.Logger; + context.Logger = loggerCache.TryGetValue(hashData.Sha256, out CachingLogger logger) + ? logger + : (loggerCache[hashData.Sha256] = (CachingLogger)context.Logger); } - context.Logger = logger; } await readyToScanChannel.Writer.WriteAsync(index);