mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Fix memory leak when accessing a const Node with a key that doesn't exist.
This commit is contained in:
@@ -192,16 +192,17 @@ void node_data::insert(node& key, node& value, shared_memory_holder pMemory) {
|
||||
}
|
||||
|
||||
// indexing
|
||||
node& node_data::get(node& key, shared_memory_holder pMemory) const {
|
||||
if (m_type != NodeType::Map)
|
||||
return pMemory->create_node();
|
||||
node* node_data::get(node& key, shared_memory_holder /* pMemory */) const {
|
||||
if (m_type != NodeType::Map) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) {
|
||||
if (it->first->is(key))
|
||||
return *it->second;
|
||||
return it->second;
|
||||
}
|
||||
|
||||
return pMemory->create_node();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
node& node_data::get(node& key, shared_memory_holder pMemory) {
|
||||
|
Reference in New Issue
Block a user