From b9d620e454ff42451f9fc7c3c58aac368fd99f3e Mon Sep 17 00:00:00 2001
From: Florent Lamiraux <florent@laas.fr>
Date: Sat, 18 Jul 2015 11:09:46 +0200
Subject: [PATCH] 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.
---
 include/hpp/manipulation/container.hh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/hpp/manipulation/container.hh b/include/hpp/manipulation/container.hh
index 0036d1c..d9d8b5f 100644
--- a/include/hpp/manipulation/container.hh
+++ b/include/hpp/manipulation/container.hh
@@ -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
-- 
GitLab