From: Rafael Espindola Date: Sat, 24 Jul 2010 23:02:11 +0000 (+0000) Subject: Fix a trivial use after free. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=97595eb05c28b25a7042d6fa1a2e0f3099506a1e;p=oota-llvm.git Fix a trivial use after free. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109363 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp index 3149a7a494a..df14aab3dfa 100644 --- a/tools/bugpoint/ToolRunner.cpp +++ b/tools/bugpoint/ToolRunner.cpp @@ -719,7 +719,11 @@ int GCC::ExecuteProgram(const std::string &ProgramFile, return -1; } - std::vector ProgramArgs; + std::vector ProgramArgs; + + // Declared here so that the destructor only runs after + // ProgramArgs is used. + std::string Exec; if (RemoteClientPath.isEmpty()) ProgramArgs.push_back(OutputBinary.c_str()); @@ -741,7 +745,7 @@ int GCC::ExecuteProgram(const std::string &ProgramFile, // Full path to the binary. We need to cd to the exec directory because // there is a dylib there that the exec expects to find in the CWD char* env_pwd = getenv("PWD"); - std::string Exec = "cd "; + Exec = "cd "; Exec += env_pwd; Exec += "; ./"; Exec += OutputBinary.c_str();