Fix invalid iterator usage in Application::close_XML_File

The iterator 'b' is invalidated by calling erase(b), which means that the
subsequent call to ++b results in undefined behavior. This was identified by
segfaults in the Matlab unit test on OS X.
This commit is contained in:
Ray Speth
2015-06-08 17:20:54 -04:00
parent 2256cd03de
commit 8dcde36d20

View File

@@ -306,8 +306,8 @@ void Application::close_XML_File(const std::string& file)
for (; b != e; ++b) {
b->second.first->unlock();
delete b->second.first;
xmlfiles.erase(b->first);
}
xmlfiles.clear();
} else if (xmlfiles.find(file) != xmlfiles.end()) {
xmlfiles[file].first->unlock();
delete xmlfiles[file].first;