LowerTypeTests: Fix use-after-free. Found by asan/msan.
authorPeter Collingbourne <peter@pcc.me.uk>
Sat, 21 Jan 2017 01:57:44 +0000 (01:57 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Sat, 21 Jan 2017 01:57:44 +0000 (01:57 +0000)
llvm-svn: 292700

llvm/lib/Transforms/IPO/LowerTypeTests.cpp

index 9ceb76a..c7b9564 100644 (file)
@@ -1344,8 +1344,11 @@ bool LowerTypeTestsModule::lower() {
     return false;
 
   if (Action == SummaryAction::Import) {
-    for (const Use &U : TypeTestFunc->uses())
-      importTypeTest(cast<CallInst>(U.getUser()));
+    for (auto UI = TypeTestFunc->use_begin(), UE = TypeTestFunc->use_end();
+         UI != UE;) {
+      auto *CI = cast<CallInst>((*UI++).getUser());
+      importTypeTest(CI);
+    }
     return true;
   }