From: Benjamin Kramer Date: Thu, 18 Feb 2010 12:57:05 +0000 (+0000) Subject: Avoid a dangling pointer dereference, PassManager::add can delete the Pass. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=3460f221cd9d3329aefb3f10a0f9d0800d8db70a;p=oota-llvm.git Avoid a dangling pointer dereference, PassManager::add can delete the Pass. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96576 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index 520018005f1..b123d54eeea 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -475,10 +475,11 @@ int main(int argc, char **argv) { errs() << argv[0] << ": cannot create pass: " << PassInf->getPassName() << "\n"; if (P) { + PassKind Kind = P->getPassKind(); addPass(Passes, P); if (AnalyzeOnly) { - switch (P->getPassKind()) { + switch (Kind) { case PT_BasicBlock: Passes.add(new BasicBlockPassPrinter(PassInf)); break;