fix: Fixes pool of acid and other empty serializations (#1025)

Fixes an issue where 0 byte objects are improperly deserialized. They should not be deserialized at all and instead deleted.
This commit is contained in:
Kamron Batman 2022-05-18 17:36:23 -07:00 committed by GitHub
parent 6b3617b08f
commit dfdadd3204
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -200,6 +200,12 @@ namespace Server
continue;
}
if (entry.Length == 0)
{
t.Delete();
continue;
}
var buffer = GC.AllocateUninitializedArray<byte>(entry.Length);
if (br == null)
{
@ -310,6 +316,12 @@ namespace Server
{
var saveBuffer = entity.SaveBuffer;
// If nothing was serialized we expect the object to be deleted on deserialization
if (saveBuffer.Position == 0)
{
return;
}
// Resize to the exact size
saveBuffer.Resize((int)saveBuffer.Position);