summaryrefslogtreecommitdiff
path: root/lib/VMCore/LLVMContextImpl.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-10-14 08:48:40 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-10-14 08:48:40 +0000
commitfd8d62c0b449b9070dc18355ac243c7fa78d40d6 (patch)
tree217a7899748c9240a5da0dfb1f63e603b57b533d /lib/VMCore/LLVMContextImpl.cpp
parent2492a38afcbb8e51454954f73c4d43f87cdd4c88 (diff)
downloadllvm-fd8d62c0b449b9070dc18355ac243c7fa78d40d6.tar.gz
llvm-fd8d62c0b449b9070dc18355ac243c7fa78d40d6.tar.bz2
llvm-fd8d62c0b449b9070dc18355ac243c7fa78d40d6.tar.xz
Fix use after free when deleting attributes in a chained folding set.
Can't follow the intrusive linked list when the element is gone. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165898 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/LLVMContextImpl.cpp')
-rw-r--r--lib/VMCore/LLVMContextImpl.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/VMCore/LLVMContextImpl.cpp b/lib/VMCore/LLVMContextImpl.cpp
index a86363b632..74247bdde1 100644
--- a/lib/VMCore/LLVMContextImpl.cpp
+++ b/lib/VMCore/LLVMContextImpl.cpp
@@ -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;