From: Zachary Turner Date: Tue, 3 Jul 2018 18:12:39 +0000 (+0000) Subject: Fix crash in clang. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a0c03f2df39aa547e4182dcf632ba1c1d533da4e;p=clang Fix crash in clang. This happened during a recent refactor. toStringRefArray() returns a vector, which was being implicitly converted to an ArrayRef, 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336219 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Job.cpp b/lib/Driver/Job.cpp index 74af597ad3..bd1a9bd8e3 100644 --- a/lib/Driver/Job.cpp +++ b/lib/Driver/Job.cpp @@ -318,10 +318,12 @@ int Command::Execute(ArrayRef> Redirects, SmallVector Argv; Optional> Env; + std::vector 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) {