]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/filestore/test_idempotent.cc: fix ~TestFileStoreState()
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Mon, 18 Mar 2013 13:34:37 +0000 (14:34 +0100)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Mon, 18 Mar 2013 13:34:37 +0000 (14:34 +0100)
Fix interator handling in ~TestFileStoreState(). After std::map::erase()
the used iterator is invalid. Use a while-loop and erase the object with
post-incremented iterator instead.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/test/filestore/TestFileStoreState.h

index 74276b03f70f8b06019dfc9b83be1191604e90e4..d3bba692437100cc7c36a459eb6e139ce76d028f 100644 (file)
@@ -99,10 +99,10 @@ public:
   }
   ~TestFileStoreState() { 
     map<int, coll_entry_t*>::iterator it = m_collections.begin();
-    for (; it != m_collections.end(); it++) {
-       if (it->second)
-           delete it->second;
-       m_collections.erase(it);
+    while (it != m_collections.end()) {
+      if (it->second)
+       delete it->second;
+      m_collections.erase(it++);
     }
   }