From c0b7c80fe62881f41aa5f389fd13defd7e037cdd Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Wed, 18 Feb 2015 14:13:46 +0000 Subject: [PATCH] Prevent use after free caused by accessing a member into a dense set. The member gets invalidated as elements are added to the dense set. Directly access the underlying pointer instead. Not sure how to create a test case for this :-(. Maybe Richard can help. llvm-svn: 229673 --- clang/lib/Serialization/ASTReader.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index a0cb7b506bdb..3125b8e43e94 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -6628,7 +6628,8 @@ ASTReader::FindExternalVisibleDeclsByName(const DeclContext *DC, auto Merged = MergedLookups.find(DC); if (Merged != MergedLookups.end()) { for (unsigned I = 0; I != Merged->second.size(); ++I) { - LookUpInContexts(Merged->second[I]); + const DeclContext *Context = Merged->second[I]; + LookUpInContexts(Context); // We might have just added some more merged lookups. If so, our // iterator is now invalid, so grab a fresh one before continuing. Merged = MergedLookups.find(DC);