From 83d671bdd0070bd565314a068189d46c399eec80 Mon Sep 17 00:00:00 2001 From: Endel Dreyer Date: Sat, 29 Feb 2020 18:38:54 -0300 Subject: [PATCH] prevent index out of bounds when parsing empty state --- Assets/Plugins/Colyseus/Serializer/Schema/Schema.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Assets/Plugins/Colyseus/Serializer/Schema/Schema.cs b/Assets/Plugins/Colyseus/Serializer/Schema/Schema.cs index 61812a1e..66e881bd 100644 --- a/Assets/Plugins/Colyseus/Serializer/Schema/Schema.cs +++ b/Assets/Plugins/Colyseus/Serializer/Schema/Schema.cs @@ -463,14 +463,14 @@ public void Decode(byte[] bytes, Iterator it = null) var changes = new List(); var totalBytes = bytes.Length; - // skip TYPE_ID of existing instances - if (bytes[it.Offset] == (byte) SPEC.TYPE_ID) - { - it.Offset += 2; - } - while (it.Offset < totalBytes) { + // skip TYPE_ID of existing instances + if (bytes[it.Offset] == (byte) SPEC.TYPE_ID) + { + it.Offset += 2; + } + var isNil = decode.NilCheck(bytes, it); if (isNil) { it.Offset++; }