[sword-svn] r2637 - trunk/src/mgr

scribe at crosswire.org scribe at crosswire.org
Fri Jul 8 13:37:47 MST 2011


Author: scribe
Date: 2011-07-08 13:37:47 -0700 (Fri, 08 Jul 2011)
New Revision: 2637

Modified:
   trunk/src/mgr/swmgr.cpp
Log:
Fixed bug which attempts to used iterator invalidated by erase


Modified: trunk/src/mgr/swmgr.cpp
===================================================================
--- trunk/src/mgr/swmgr.cpp	2011-07-07 19:28:53 UTC (rev 2636)
+++ trunk/src/mgr/swmgr.cpp	2011-07-08 20:37:47 UTC (rev 2637)
@@ -723,7 +723,7 @@
 			// fix config's Section names to rename modules which are available more than once
 			// find out which sections are in both config objects
 			// inserting all configs first is not good because that overwrites old keys and new modules would share the same config
-			for (SectionMap::iterator it = config->Sections.begin(); it != config->Sections.end(); ++it) {
+			for (SectionMap::iterator it = config->Sections.begin(); it != config->Sections.end();) {
 				if (saveConfig->Sections.find( (*it).first ) != saveConfig->Sections.end()) { //if the new section is already present rename it
 					ConfigEntMap entMap((*it).second);
 					
@@ -735,8 +735,10 @@
 					} while (config->Sections.find(name) != config->Sections.end());
 					
 					config->Sections.insert(SectionMap::value_type(name, entMap) );
-					config->Sections.erase(it);
+					SectionMap::iterator toErase = it++;
+					config->Sections.erase(toErase);
 				}
+				else ++it;
 			}
 		}
 		




More information about the sword-cvs mailing list