Skip to content

Commit

Permalink
fix: Fixes reading multiple strings (books) (#1814)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamronbatman committed Jun 2, 2024
1 parent 5f8f798 commit aeba226
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Projects/Server/Buffers/SpanReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,12 @@ public string ReadString(Encoding encoding, bool safeString = false, int fixedLe

var span = _buffer.Slice(Position, size);
var index = span.IndexOfTerminator(byteLength);
span = _buffer.Slice(Position, index);

Position += isFixedLength || index < 0 ? size : index;
Position += isFixedLength || index < 0 ? size : index + 1;

// The string is either as long as the first terminator character, remaining buffer size, or fixed length.
return TextEncoding.GetString(span[..(index < 0 ? size : index)], encoding, safeString);
return TextEncoding.GetString(span, encoding, safeString);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down

0 comments on commit aeba226

Please sign in to comment.