Skip to content

Commit

Permalink
Merge pull request #871 from dotnet/fix870
Browse files Browse the repository at this point in the history
Fix ArgumentNullException thrown when reading empty strings from git database
  • Loading branch information
AArnott committed Dec 5, 2022
2 parents b7d359e + 1c45336 commit 4c54ddd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/NerdBank.GitVersioning/ManagedGit/GitRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,11 @@ private static bool TryConvertHexStringToByteArray(string hexString, Span<byte>
/// </returns>
public static unsafe string GetString(ReadOnlySpan<byte> bytes)
{
if (bytes.Length == 0)
{
return string.Empty;
}

fixed (byte* pBytes = bytes)
{
return Encoding.GetString(pBytes, bytes.Length);
Expand Down

0 comments on commit 4c54ddd

Please sign in to comment.