Fix memory leak when accessing a const Node with a key that doesn't exist.

This commit is contained in:
Jesse Beder
2015-01-24 17:22:45 -06:00
parent a5e86cde59
commit 1025f76df1
8 changed files with 41 additions and 26 deletions

View File

@@ -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) {