[IOT-2412]Segment faults in ResourceContainerImpl
authorabitha.s <abitha.s@samsung.com>
Wed, 28 Jun 2017 13:24:18 +0000 (18:54 +0530)
committerUze Choi <uzchoi@samsung.com>
Mon, 3 Jul 2017 08:12:26 +0000 (08:12 +0000)
function is calling erase on the map container which will invalidate it. Hence, added guard calls.

Change-Id: I555895089d8dfa0a3a7f0d804dd5ccef8e4e1ece
Signed-off-by: abitha.s <abitha.s@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/21097
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/resource-container/src/ResourceContainerImpl.cpp

index 8fd9a56..1360ad2 100644 (file)
@@ -126,10 +126,12 @@ namespace OIC
 
             activationLock.lock();
             for (std::map< std::string, shared_ptr<BundleInfoInternal> >::iterator it = m_bundles.begin();
-                 it != m_bundles.end(); ++it)
+                 it != m_bundles.end();)
             {
+                auto next_itr = std::next (it, 1);
                 deactivateBundle(it->second);
                 unregisterBundle(it->second);
+                it = next_itr;
             }
 
             if (!m_mapServers.empty())