From dfdadd3204047f8c2f7185ace2828fcc033a5821 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Wed, 18 May 2022 17:36:23 -0700 Subject: [PATCH] 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. --- Projects/Server/World/EntityPersistence.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Projects/Server/World/EntityPersistence.cs b/Projects/Server/World/EntityPersistence.cs index bf2f415df..59a9d5e80 100644 --- a/Projects/Server/World/EntityPersistence.cs +++ b/Projects/Server/World/EntityPersistence.cs @@ -200,6 +200,12 @@ namespace Server continue; } + if (entry.Length == 0) + { + t.Delete(); + continue; + } + var buffer = GC.AllocateUninitializedArray(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);