From 5fad75b2c265bbd6b2bfb9d4f61d2dc53f2e8ab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Wockenfu=C3=9F?= Date: Sat, 18 Jan 2025 21:19:38 +0100 Subject: [PATCH] ArgumentOutOfRangeException Bugfix MessageDeserializer.cs::Read(out string value) threw an error as soon as NaN values were present in the points of the mesh. Zero values were therefore given and one was subtracted from them due to ROS2 conditions. This resulted in negative becoming in a counting variable --- .../Runtime/MessageGeneration/MessageDeserializer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.robotics.ros-tcp-connector/Runtime/MessageGeneration/MessageDeserializer.cs b/com.unity.robotics.ros-tcp-connector/Runtime/MessageGeneration/MessageDeserializer.cs index a1335c85..9c7c30a0 100644 --- a/com.unity.robotics.ros-tcp-connector/Runtime/MessageGeneration/MessageDeserializer.cs +++ b/com.unity.robotics.ros-tcp-connector/Runtime/MessageGeneration/MessageDeserializer.cs @@ -138,7 +138,7 @@ public void Read(out string value) value = System.Text.Encoding.UTF8.GetString(data, offset, length); #else // ROS2 strings have a null byte at the end - value = System.Text.Encoding.UTF8.GetString(data, offset, length - 1); + value = System.Text.Encoding.UTF8.GetString(data, offset, Math.Max(0, length - 1)); #endif offset += length; }