diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2024-11-05 22:11:18 +0200 |
---|---|---|
committer | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2024-11-06 00:51:20 +0200 |
commit | 55732f7343fa574a8dfcbfd807e69b1fb56e9209 (patch) | |
tree | 2e19a9ad7bf4b0bee309447c99cf7c6616e7ebcc | |
parent | a9e0bc996e6b644f99ae033e6b35daac0c49e0e1 (diff) |
viewer#3010 Fix malfunctioning json array to llsd parsing
Was reserving 'size' elements, then appending more elements on top.
-rw-r--r-- | indra/llcommon/llsdjson.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
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; } |