Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/Tmds.DBus.Protocol/AddressReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal AddressEntry(string s, int offset, int count) =>
public static bool TryGetNextEntry(string addresses, ref AddressEntry address)
{
int offset = address.String is null ? 0 : address.Offset + address.Count + 1;
if (offset >= addresses.Length - 1)
if (offset >= addresses.Length)
{
return false;
}
Expand Down Expand Up @@ -145,7 +145,9 @@ private static string Unescape(ReadOnlySpan<char> value)
{
return value.AsString();
}
Span<char> unescaped = stackalloc char[Constants.StackAllocCharThreshold];
Span<char> unescaped = value.Length <= Constants.StackAllocCharThreshold
? stackalloc char[Constants.StackAllocCharThreshold]
: new char[value.Length];
int pos = 0;
for (int i = 0; i < value.Length;)
{
Expand All @@ -154,7 +156,7 @@ private static string Unescape(ReadOnlySpan<char> value)
{
unescaped[pos++] = c;
}
else if (i + 2 < value.Length)
else if (i + 2 <= value.Length)
{
int a = FromHexChar(value[i++]);
int b = FromHexChar(value[i++]);
Expand Down
Loading