]> granicus.if.org Git - llvm/commitdiff
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)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292700 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/LowerTypeTests.cpp

index 9ceb76a8e35411d872f246c76b3ddb3760914230..c7b9564c63fb9612043d5a7d9ceff4550aa36e4b 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;
   }