Skip to content

Commit c5cf7d2

Browse files
committed
[Proto] Fix InvalidBufferSize for String Writing
1 parent 5c39816 commit c5cf7d2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Lagrange.Proto/Primitives/ProtoWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void EncodeString(ReadOnlySpan<char> str)
4242
int min = ProtoHelper.GetVarIntMin(count);
4343
int max = ProtoHelper.GetVarIntMax(count);
4444
int utf16Max = ProtoConstants.MaxExpansionFactorWhileTranscoding * str.Length;
45-
if (_memory.Length < utf16Max + count) Grow(utf16Max + count);
45+
if (_memory.Length - BytesPending < utf16Max + count) Grow(utf16Max + count);
4646

4747
if (str.Length + count > min && utf16Max + count < max) // falls within the range
4848
{

0 commit comments

Comments
 (0)