Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
FirstGearGames committed May 2, 2022
2 parents 4b12748 + 0198aa5 commit cdb2611
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Assets/FishNet/Runtime/Serializing/Writer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,10 @@ public void WriteString(string value)
* never intentionally inflict allocations on itself.
* Reader ensures string count cannot exceed received
* packet size. */
if (value.Length >= _stringBuffer.Length)
int valueMaxBytes = _encoding.GetMaxByteCount(value.Length);
if (valueMaxBytes >= _stringBuffer.Length)
{
int nextSize = (_stringBuffer.Length * 2) + value.Length;
int nextSize = (_stringBuffer.Length * 2) + valueMaxBytes;
Array.Resize(ref _stringBuffer, nextSize);
}

Expand Down

0 comments on commit cdb2611

Please sign in to comment.