From: Kostya Serebryany Date: Wed, 19 Apr 2017 20:57:13 +0000 (+0000) Subject: Fix a leak in tools/driver/cc1as_main.cpp X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f8562bd6ceeff06973cf4519b79e10b900e0752d;p=clang Fix a leak in tools/driver/cc1as_main.cpp Summary: For some reason, the asan bot has recently started reporting this leak even though it existed for ages. Reviewers: pcc Reviewed By: pcc Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D32243 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300755 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/driver/cc1as_main.cpp b/tools/driver/cc1as_main.cpp index 2fa8edb81a..33d957658c 100644 --- a/tools/driver/cc1as_main.cpp +++ b/tools/driver/cc1as_main.cpp @@ -506,12 +506,12 @@ int cc1as_main(ArrayRef Argv, const char *Argv0, void *MainAddr) { // FIXME: Remove this, one day. if (!Asm.LLVMArgs.empty()) { unsigned NumArgs = Asm.LLVMArgs.size(); - const char **Args = new const char*[NumArgs + 2]; + auto Args = llvm::make_unique(NumArgs + 2); Args[0] = "clang (LLVM option parsing)"; for (unsigned i = 0; i != NumArgs; ++i) Args[i + 1] = Asm.LLVMArgs[i].c_str(); Args[NumArgs + 1] = nullptr; - llvm::cl::ParseCommandLineOptions(NumArgs + 1, Args); + llvm::cl::ParseCommandLineOptions(NumArgs + 1, Args.get()); } // Execute the invocation, unless there were parsing errors.