Skip to content

Commit 55732f7

Browse files
committed
viewer#3010 Fix malfunctioning json array to llsd parsing
Was reserving 'size' elements, then appending more elements on top.
1 parent a9e0bc9 commit 55732f7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

indra/llcommon/llsdjson.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,16 @@ LLSD LlsdFromJson(const boost::json::value& val)
6363
case boost::json::kind::array:
6464
{
6565
result = LLSD::emptyArray();
66-
auto& array = val.as_array();
66+
const boost::json::array& array = val.as_array();
67+
size_t size = array.size();
6768
// allocate elements 0 .. (size() - 1) to avoid incremental allocation
6869
if (! array.empty())
6970
{
70-
result[array.size() - 1] = LLSD();
71+
result[size - 1] = LLSD();
7172
}
72-
for (const auto &element : array)
73+
for (size_t i = 0; i < size; i++)
7374
{
74-
result.append(LlsdFromJson(element));
75+
result[i] = (LlsdFromJson(array[i]));
7576
}
7677
break;
7778
}

0 commit comments

Comments
 (0)