r300755 - Fix a leak in tools/driver/cc1as_main.cpp

Kostya Serebryany via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 19 13:57:13 PDT 2017


Author: kcc
Date: Wed Apr 19 15:57:13 2017
New Revision: 300755

URL: http://llvm.org/viewvc/llvm-project?rev=300755&view=rev
Log:
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

Modified:
    cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=300755&r1=300754&r2=300755&view=diff
==============================================================================
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Wed Apr 19 15:57:13 2017
@@ -506,12 +506,12 @@ int cc1as_main(ArrayRef<const char *> Ar
   // 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.




More information about the cfe-commits mailing list