Skip to content

Commit 4c54ddd

Browse files
authored
Merge pull request #871 from dotnet/fix870
Fix ArgumentNullException thrown when reading empty strings from git database
2 parents b7d359e + 1c45336 commit 4c54ddd

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/NerdBank.GitVersioning/ManagedGit/GitRepository.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,11 @@ private static bool TryConvertHexStringToByteArray(string hexString, Span<byte>
719719
/// </returns>
720720
public static unsafe string GetString(ReadOnlySpan<byte> bytes)
721721
{
722+
if (bytes.Length == 0)
723+
{
724+
return string.Empty;
725+
}
726+
722727
fixed (byte* pBytes = bytes)
723728
{
724729
return Encoding.GetString(pBytes, bytes.Length);

0 commit comments

Comments
 (0)