UB in clangpch_cache.cpp
Posted: Mon Sep 30, 2013 2:05 am
In LiteEditor/clangpch_cache.cpp
When an element is found, it is deleted, which invalidates "iter", but then iter is dereferenced, which triggers an undefined behavior.
Code: Select all
void ClangTUCache::RemoveEntry(const wxString& filename)
{
std::map<wxString, ClangCacheEntry>::iterator iter = m_cache.find(filename);
if(iter != m_cache.end()) {
CL_DEBUG(wxT("clang_disposeTranslationUnit for TU: %p"), (void*)iter->second.TU);
clang_disposeTranslationUnit(iter->second.TU);
m_cache.erase(iter);
wxLogNull nolog;
wxRemoveFile(iter->second.fileTU);
}
}