Skip to content

Commit

Permalink
Fix several user reported issue NullReferenceException (#2596)
Browse files Browse the repository at this point in the history
* fix hashData?.Sha256 == null

* add Release History

* fix comment

Co-authored-by: Michael C. Fanning <[email protected]>
  • Loading branch information
shaopeng-gh and michaelcfanning authored Dec 28, 2022
1 parent 80cb48e commit 2f03914
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/ReleaseHistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 4 additions & 3 deletions src/Sarif.Driver/Sdk/MultithreadedAnalyzeCommandBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -513,11 +513,12 @@ private async Task<bool> HashFilesAndPutInAnalysisQueueAsnc()

loggerCache ??= new Dictionary<string, CachingLogger>();

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);
Expand Down

0 comments on commit 2f03914

Please sign in to comment.