From 5a0657b8bb041317487f12970443826a95cb5c24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albin=20Cor=C3=A9n?= Date: Wed, 11 Dec 2019 19:58:26 +0100 Subject: [PATCH] fix: Fixed exception when reliable window is exhausted and memory manager is trying to dealloc null pointers --- Ruffles/Messaging/PacketHandler.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Ruffles/Messaging/PacketHandler.cs b/Ruffles/Messaging/PacketHandler.cs index 5d4e344..40a56f3 100644 --- a/Ruffles/Messaging/PacketHandler.cs +++ b/Ruffles/Messaging/PacketHandler.cs @@ -101,19 +101,19 @@ internal static void SendMessage(ArraySegment payload, Connection connecti { connection.SendRaw(new ArraySegment(((HeapMemory)memoryPointers.Pointers[i]).Buffer, (int)((HeapMemory)memoryPointers.Pointers[i]).VirtualOffset, (int)((HeapMemory)memoryPointers.Pointers[i]).VirtualCount), noDelay, headerSize); } - } - if (dealloc) - { - // DeAlloc the memory again. This is done for unreliable channels that dont need the message after the initial send. - for (int i = 0; i < memoryPointers.VirtualCount; i++) + if (dealloc) { - memoryManager.DeAlloc(((HeapMemory)memoryPointers.Pointers[i])); + // DeAlloc the memory again. This is done for unreliable channels that dont need the message after the initial send. + for (int i = 0; i < memoryPointers.VirtualCount; i++) + { + memoryManager.DeAlloc(((HeapMemory)memoryPointers.Pointers[i])); + } } - } - // Dealloc the array always. - memoryManager.DeAlloc(memoryPointers); + // Dealloc the array always. + memoryManager.DeAlloc(memoryPointers); + } } } }