From 902ee8effa1d551f1ab796619dadacf54e0831f2 Mon Sep 17 00:00:00 2001 From: Nicolas Rabault Date: Thu, 1 Feb 2024 12:57:45 +0100 Subject: [PATCH] [Gate] Avoid to crash when receiving a traj with no value --- tool_services/gate/TinyJSON/convert.c | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tool_services/gate/TinyJSON/convert.c b/tool_services/gate/TinyJSON/convert.c index 2dcd7559a..f115e96ea 100644 --- a/tool_services/gate/TinyJSON/convert.c +++ b/tool_services/gate/TinyJSON/convert.c @@ -200,6 +200,11 @@ void Convert_JsonToMsg(service_t *service, uint16_t id, luos_type_t type, char * int i = 0; // this is a trajectory int size = (int)json_getInteger(json_getChild(jobj)); + if (size == 0) + { + // This trajaectory is empty + return; + } // find the first \r of the current buf for (i = 0; i < GATE_BUFF_SIZE; i++) { @@ -308,6 +313,11 @@ void Convert_JsonToMsg(service_t *service, uint16_t id, luos_type_t type, char * int i = 0; // this is a trajectory int size = (int)json_getInteger(json_getChild(jobj)); + if (size == 0) + { + // This trajaectory is empty + return; + } // find the first \r of the current buf for (i = 0; i < GATE_BUFF_SIZE; i++) { @@ -341,6 +351,11 @@ void Convert_JsonToMsg(service_t *service, uint16_t id, luos_type_t type, char * int i = 0; // this is a trajectory int size = (int)json_getInteger(json_getChild(jobj)); + if (size == 0) + { + // This trajaectory is empty + return; + } // find the first \r of the current buf for (i = 0; i < GATE_BUFF_SIZE; i++) { @@ -492,6 +507,11 @@ void Convert_JsonToMsg(service_t *service, uint16_t id, luos_type_t type, char * int i = 0; // This is a binary int size = (int)json_getInteger(item); + if (size == 0) + { + // This trajaectory is empty + return; + } // find the first \r of the current buf for (i = 0; i < GATE_BUFF_SIZE; i++) { @@ -620,6 +640,11 @@ void Convert_JsonToMsg(service_t *service, uint16_t id, luos_type_t type, char * int i = 0; // This is a binary unsigned int size = (int)json_getInteger(jobj); + if (size == 0) + { + // This trajaectory is empty + return; + } // find the first \r of the current buf for (i = 0; i < GATE_BUFF_SIZE; i++) { @@ -663,6 +688,11 @@ void Convert_JsonToMsg(service_t *service, uint16_t id, luos_type_t type, char * int i = 0; // This is a binary unsigned int size = (int)json_getInteger(item); + if (size == 0) + { + // This trajaectory is empty + return; + } // find the first \r of the current buf for (i = 0; i < GATE_BUFF_SIZE; i++) {