From 4c116526d24c68271ca2da1431eb37339d4f6267 Mon Sep 17 00:00:00 2001
From: Thomas Goyne <plorkyeran@aegisub.org>
Date: Tue, 16 Oct 2012 09:47:06 -0700
Subject: [PATCH] Fix an occasional crash on startup on Windows debug builds

Some of the debug iterator code seems to not like 'delete map[key]', so
change things a little to do things in a way that appears to be fine.
---
 aegisub/libaegisub/common/option_visit.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/aegisub/libaegisub/common/option_visit.cpp b/aegisub/libaegisub/common/option_visit.cpp
index abe19f207..f3b84c681 100644
--- a/aegisub/libaegisub/common/option_visit.cpp
+++ b/aegisub/libaegisub/common/option_visit.cpp
@@ -144,11 +144,12 @@ void ConfigVisitor::AddOptionValue(OptionValue* opt) {
 		return;
 	}
 
-	if (!values.count(name))
+	OptionValueMap::iterator it = values.find(name);
+	if (it == values.end())
 		values[name] = opt;
 	else if (replace) {
-		delete values[name];
-		values[name] = opt;
+		delete it->second;
+		it->second = opt;
 	}
 	else {
 		try {
-- 
GitLab