diff options
| author | Zachary Turner <zturner@google.com> | 2018-07-03 18:12:39 +0000 | 
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2018-07-03 18:12:39 +0000 | 
| commit | 4ca9432defc3c80d8247d16e0b7f0fb15c0f49f2 (patch) | |
| tree | f76d05e9aaa76ca7badde5a799605ebaf7090665 | |
| parent | adc51ae4255044fe3ba50768013d7f47b2102c79 (diff) | |
| download | bcm5719-llvm-4ca9432defc3c80d8247d16e0b7f0fb15c0f49f2.tar.gz bcm5719-llvm-4ca9432defc3c80d8247d16e0b7f0fb15c0f49f2.zip  | |
Fix crash in clang.
This happened during a recent refactor.  toStringRefArray() returns
a vector<StringRef>, which was being implicitly converted to an
ArrayRef<StringRef>, and then the vector was immediately being
destroyed, so the ArrayRef<> was losing its backing storage.
Fix this by making sure the vector gets permanent storage.
llvm-svn: 336219
| -rw-r--r-- | clang/lib/Driver/Job.cpp | 4 | 
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/Driver/Job.cpp b/clang/lib/Driver/Job.cpp index 74af597ad36..bd1a9bd8e3e 100644 --- a/clang/lib/Driver/Job.cpp +++ b/clang/lib/Driver/Job.cpp @@ -318,10 +318,12 @@ int Command::Execute(ArrayRef<llvm::Optional<StringRef>> Redirects,    SmallVector<const char*, 128> Argv;    Optional<ArrayRef<StringRef>> Env; +  std::vector<StringRef> ArgvVectorStorage;    if (!Environment.empty()) {      assert(Environment.back() == nullptr &&             "Environment vector should be null-terminated by now"); -    Env = llvm::toStringRefArray(Environment.data()); +    ArgvVectorStorage = llvm::toStringRefArray(Environment.data()); +    Env = makeArrayRef(ArgvVectorStorage);    }    if (ResponseFile == nullptr) {  | 

