From 8dcde36d2087b36a67a8d9f6d1e7855a7ea487da Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Mon, 8 Jun 2015 17:20:54 -0400 Subject: [PATCH] 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. --- src/base/application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base/application.cpp b/src/base/application.cpp index 92bc58681..467387581 100644 --- a/src/base/application.cpp +++ b/src/base/application.cpp @@ -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;