Skip to content

Commit

Permalink
Fix invalid iterator usage in Application::close_XML_File
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
speth committed Jun 8, 2015
1 parent 2256cd0 commit 8dcde36
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/base/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8dcde36

Please sign in to comment.