Skip to content
Snippets Groups Projects
Commit b9d620e4 authored by Florent Lamiraux's avatar Florent Lamiraux
Browse files

Fix memory access error

  - In method Container::get, when a wrong key was provided, a new element was
    created and a const ref to this element was returned by the method. The
    problem was that the element created was destroyed when leaving the
    method and the const ref became a const ref to nothing.
parent 6f53f9db
No related branches found
No related tags found
No related merge requests found
......@@ -39,7 +39,7 @@ namespace hpp {
const Element& get (const Key& name) const
{
typename ElementMap_t::const_iterator it = map_.find (name);
if (it == map_.end ()) return Element ();
if (it == map_.end ()) return default_;
return it->second;
}
......@@ -78,6 +78,8 @@ namespace hpp {
private:
ElementMap_t map_;
/// Element returned by method get when key does not belong to map.
Element default_;
}; // class Container
} // namespace manipulation
} // namespace hpp
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment