r229673 - Prevent use after free caused by accessing a member into a dense set.

Daniel Jasper djasper at google.com
Wed Feb 18 06:13:46 PST 2015


Author: djasper
Date: Wed Feb 18 08:13:46 2015
New Revision: 229673

URL: http://llvm.org/viewvc/llvm-project?rev=229673&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=229673&r1=229672&r2=229673&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Wed Feb 18 08:13:46 2015
@@ -6628,7 +6628,8 @@ ASTReader::FindExternalVisibleDeclsByNam
       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);





More information about the cfe-commits mailing list