[llvm] r278912 - [LTO] Fix a use-after-free introduced in r278907 and caught by ASan.
Chandler Carruth via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 17 00:48:34 PDT 2016
Author: chandlerc
Date: Wed Aug 17 02:48:34 2016
New Revision: 278912
URL: http://llvm.org/viewvc/llvm-project?rev=278912&view=rev
Log:
[LTO] Fix a use-after-free introduced in r278907 and caught by ASan.
The ASan build bot caught this right away:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/15580/steps/check-llvm%20asan/logs/stdio
This was also breaking a Windows build bot I'm pretty sure.
Modified:
llvm/trunk/tools/llvm-lto2/llvm-lto2.cpp
Modified: llvm/trunk/tools/llvm-lto2/llvm-lto2.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-lto2/llvm-lto2.cpp?rev=278912&r1=278911&r2=278912&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-lto2/llvm-lto2.cpp (original)
+++ llvm/trunk/tools/llvm-lto2/llvm-lto2.cpp Wed Aug 17 02:48:34 2016
@@ -77,10 +77,10 @@ template <typename T> static T check(Err
namespace {
// Define the LTOOutput handling
class LTOOutput : public lto::NativeObjectOutput {
- StringRef Path;
+ std::string Path;
public:
- LTOOutput(StringRef Path) : Path(Path) {}
+ LTOOutput(std::string Path) : Path(std::move(Path)) {}
std::unique_ptr<raw_pwrite_stream> getStream() override {
std::error_code EC;
auto S = llvm::make_unique<raw_fd_ostream>(Path, EC, sys::fs::F_None);
@@ -174,7 +174,7 @@ int main(int argc, char **argv) {
auto AddOutput = [&](size_t Task) {
std::string Path = OutputFilename + "." + utostr(Task);
- return llvm::make_unique<LTOOutput>(Path);
+ return llvm::make_unique<LTOOutput>(std::move(Path));
};
check(Lto.run(AddOutput), "LTO::run failed");
More information about the llvm-commits
mailing list