mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-10 04:51:17 +00:00
Fix sequence sometimes not turning into a map (#450)
Previously, just referencing the next element in the sequence (and so constructing it, as an undefined element) would allow you to skip defining an element without turning the sequence into a map. E.g: node[0] = "foo"; // sequence of size 1 node[1]; // sequence of size 1, with an undefined element at 1 node[2] = "bar"; // FIX: should be map of size 2 (since there's no element at index 1)
This commit is contained in:
@@ -32,7 +32,7 @@ struct get_idx<Key,
|
||||
|
||||
static node* get(std::vector<node*>& sequence, const Key& key,
|
||||
shared_memory_holder pMemory) {
|
||||
if (key > sequence.size())
|
||||
if (key > sequence.size() || (key > 0 && !sequence[key-1]->is_defined()))
|
||||
return 0;
|
||||
if (key == sequence.size())
|
||||
sequence.push_back(&pMemory->create_node());
|
||||
|
Reference in New Issue
Block a user