[llvm-commits] CVS: llvm/tools/llvmc/CompilerDriver.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Feb 13 15:10:49 PST 2005



Changes in directory llvm/tools/llvmc:

CompilerDriver.cpp updated: 1.25 -> 1.26
---
Log message:

Conform to the documented interface by null terminating argument lists!


---
Diffs of the changes:  (+5 -7)

 CompilerDriver.cpp |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)


Index: llvm/tools/llvmc/CompilerDriver.cpp
diff -u llvm/tools/llvmc/CompilerDriver.cpp:1.25 llvm/tools/llvmc/CompilerDriver.cpp:1.26
--- llvm/tools/llvmc/CompilerDriver.cpp:1.25	Sun Dec 19 22:02:01 2004
+++ llvm/tools/llvmc/CompilerDriver.cpp	Sun Feb 13 17:10:34 2005
@@ -394,22 +394,20 @@
 
       // Invoke the program
       const char** Args = (const char**) 
-        alloca(sizeof(const char*)*action->args.size());
-      for (unsigned i = 0; i != action->args.size(); ++i) {
+        alloca(sizeof(const char*)*(action->args.size()+1));
+      for (unsigned i = 0; i != action->args.size(); ++i)
         Args[i] = action->args[i].c_str();
-      }
+      Args[action->args.size()] = 0;  // null terminate list.
       if (isSet(TIME_ACTIONS_FLAG)) {
         Timer timer(action->program.toString());
         timer.startTimer();
-        int resultCode = 
-          sys::Program::ExecuteAndWait(action->program,Args);
+        int resultCode = sys::Program::ExecuteAndWait(action->program, Args);
         timer.stopTimer();
         timer.print(timer,std::cerr);
         return resultCode == 0;
       }
       else
-        return 0 == 
-          sys::Program::ExecuteAndWait(action->program, Args);
+        return 0 == sys::Program::ExecuteAndWait(action->program, Args);
     }
     return true;
   }






More information about the llvm-commits mailing list