From: Peter Collingbourne Date: Sat, 21 Jan 2017 01:57:44 +0000 (+0000) Subject: LowerTypeTests: Fix use-after-free. Found by asan/msan. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9221d610b302f5eb53b7073c6afe7eee7b21dc67;p=llvm LowerTypeTests: Fix use-after-free. Found by asan/msan. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292700 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/IPO/LowerTypeTests.cpp b/lib/Transforms/IPO/LowerTypeTests.cpp index 9ceb76a8e35..c7b9564c63f 100644 --- a/lib/Transforms/IPO/LowerTypeTests.cpp +++ b/lib/Transforms/IPO/LowerTypeTests.cpp @@ -1344,8 +1344,11 @@ bool LowerTypeTestsModule::lower() { return false; if (Action == SummaryAction::Import) { - for (const Use &U : TypeTestFunc->uses()) - importTypeTest(cast(U.getUser())); + for (auto UI = TypeTestFunc->use_begin(), UE = TypeTestFunc->use_end(); + UI != UE;) { + auto *CI = cast((*UI++).getUser()); + importTypeTest(CI); + } return true; }