From 21afba1004e6b3598f10824ef07e5cd11de2b3eb Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 3 Jul 2015 12:20:34 +0000 Subject: [PATCH] Avoid a use after free. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241345 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bitcode/Reader/BitcodeReader.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index d9ac3ad7c64..09f0b689bdc 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -4459,7 +4459,10 @@ std::error_code BitcodeReader::materialize(GlobalValue *GV) { // Upgrade any old intrinsic calls in the function. for (auto &I : UpgradedIntrinsics) { if (I.first != I.second) { - for (auto *U : I.first->users()) { + for (auto UI = I.first->user_begin(), UE = I.first->user_end(); + UI != UE;) { + User *U = *UI; + ++UI; if (CallInst *CI = dyn_cast(U)) UpgradeIntrinsicCall(CI, I.second); } -- 2.34.1