]> granicus.if.org Git - clang/commitdiff
Fix a leak in tools/driver/cc1as_main.cpp
authorKostya Serebryany <kcc@google.com>
Wed, 19 Apr 2017 20:57:13 +0000 (20:57 +0000)
committerKostya Serebryany <kcc@google.com>
Wed, 19 Apr 2017 20:57:13 +0000 (20:57 +0000)
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

tools/driver/cc1as_main.cpp

index 2fa8edb81ae476099ff58326fc48608295ba2aa9..33d957658cf05bbbd2578e95600b804b70caa9fc 100644 (file)
@@ -506,12 +506,12 @@ int cc1as_main(ArrayRef<const char *> 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<const char*[]>(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.