fix: Fixes serializing strings in GenericPersistence (#1228)

This commit is contained in:
Kamron Batman 2022-11-04 19:14:50 -07:00 committed by GitHub
parent 448e5bec7b
commit 119eec6b61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -64,7 +64,9 @@ public class BinaryFileReader : IGenericReader, IDisposable
}
byte[] buffer = STArrayPool<byte>.Shared.Rent(length);
var str = TextEncoding.GetString(buffer.AsSpan(0, length), _encoding);
var strBuffer = buffer.AsSpan(0, length);
_reader.Read(strBuffer);
var str = TextEncoding.GetString(strBuffer, _encoding);
STArrayPool<byte>.Shared.Return(buffer);
return intern ? str.Intern() : str;
}