From 93c760672389d15763b6f3c93884b781b66bc32b Mon Sep 17 00:00:00 2001 From: Pin Che Date: Mon, 22 May 2023 10:58:53 +0800 Subject: [PATCH] added code to handle empty string in deserializeIntoJson --- src/ros_parser.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ros_parser.cpp b/src/ros_parser.cpp index ec4d436..e8de8fc 100644 --- a/src/ros_parser.cpp +++ b/src/ros_parser.cpp @@ -522,7 +522,14 @@ bool Parser::deserializeIntoJson(Span buffer, std::string* json_t { throw std::runtime_error("Buffer overrun"); } - new_value.SetString(reinterpret_cast(&buffer[buffer_offset]), string_size, alloc); + if(string_size == 0) + { + new_value.SetString(""); + } + else + { + new_value.SetString(reinterpret_cast(&buffer[buffer_offset]), string_size, alloc); + } buffer_offset += string_size; } break;