[Fixed] Fix assertion fault on VS2008 debug build
Posted: Tue Jan 04, 2011 2:32 pm
				
				Prevented refering erased iterator.
			Code: Select all
diff --git a/conffile.cpp b/conffile.cpp
index 94983e7..5f437ab 100644
--- a/conffile.cpp
+++ b/conffile.cpp
@@ -459,19 +459,21 @@ char *ConfigFile::GetStringDup(const char *key, const char *def){
 bool ConfigFile::SetString(const char *key, string val, const char *comment){
     set<ConfigEntry, ConfigEntry::key_less>::iterator i;
     bool ret=false;
+    bool found;
 
     ConfigEntry e(key, val);
 	if(comment && *comment) e.comment = comment;
 	e.used=true;
 
     i=data.find(e);
-    if(i!=data.end()){
+    found=(i==data.end());
+    if(!found){
         e.line=i->line;
         data.erase(e);
 		sectionSizes.DecreaseSectionSize(e.section);
         ret=true;
     }
-	if((i==data.end() && (!alphaSort || timeSort)) || (!alphaSort && timeSort))
+	if((found && (!alphaSort || timeSort)) || (!alphaSort && timeSort))
 		e.line = linectr++;
 
     data.insert(e);