Fix use after free when deleting attributes in a chained folding set.

Can't follow the intrusive linked list when the element is gone.

llvm-svn: 165898
This commit is contained in:
Benjamin Kramer 2012-10-14 08:48:40 +00:00
parent 5ed900d026
commit 95200ba870

View File

@ -97,9 +97,11 @@ LLVMContextImpl::~LLVMContextImpl() {
// Destroy attributes.
for (FoldingSetIterator<AttributesImpl> I = AttrsSet.begin(),
E = AttrsSet.end(); I != E; ++I)
delete &*I;
E = AttrsSet.end(); I != E;) {
FoldingSetIterator<AttributesImpl> Elem = I++;
delete &*Elem;
}
// Destroy MDNodes. ~MDNode can move and remove nodes between the MDNodeSet
// and the NonUniquedMDNodes sets, so copy the values out first.
SmallVector<MDNode*, 8> MDNodes;