YAML CPP: Fix infinite loop
@@ -319,8 +319,11 @@ void addKeyArray (YAML::Node & data, NameIterator & keyIterator, Key & key, Key
if (keyIterator == --key.end ())
{
if (isArrayElement)
+ {
+ if (arrayIndex > data.size ())
{
addEmptyArrayElements (data, arrayIndex - data.size ());
+ }
data.push_back (createLeafNode (key));
}
else
@@ -336,7 +339,10 @@ void addKeyArray (YAML::Node & data, NameIterator & keyIterator, Key & key, Key
if (isArrayElement)
{
node = (arrayIndex < data.size () && !data[arrayIndex].IsScalar ()) ? data[arrayIndex] : YAML::Node ();
+ if (arrayIndex > data.size ())
+ {
addEmptyArrayElements (data, arrayIndex - data.size ());
+ }
data[arrayIndex] = node;
}
else
