From 55732f7343fa574a8dfcbfd807e69b1fb56e9209 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 5 Nov 2024 22:11:18 +0200 Subject: viewer#3010 Fix malfunctioning json array to llsd parsing Was reserving 'size' elements, then appending more elements on top. --- indra/llcommon/llsdjson.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/llsdjson.cpp b/indra/llcommon/llsdjson.cpp index 1df2a8f9eb..655869a704 100644 --- a/indra/llcommon/llsdjson.cpp +++ b/indra/llcommon/llsdjson.cpp @@ -63,15 +63,16 @@ LLSD LlsdFromJson(const boost::json::value& val) case boost::json::kind::array: { result = LLSD::emptyArray(); - auto& array = val.as_array(); + const boost::json::array& array = val.as_array(); + size_t size = array.size(); // allocate elements 0 .. (size() - 1) to avoid incremental allocation if (! array.empty()) { - result[array.size() - 1] = LLSD(); + result[size - 1] = LLSD(); } - for (const auto &element : array) + for (size_t i = 0; i < size; i++) { - result.append(LlsdFromJson(element)); + result[i] = (LlsdFromJson(array[i])); } break; } -- cgit v1.2.3