[Lldb-commits] [lldb] r192318 - Add error checking to 'cmd' buffer as it may not be available (ie. in the case of exec).
Matt Kopec
Matt.Kopec at intel.com
Wed Oct 9 12:23:35 PDT 2013
Author: mkopec
Date: Wed Oct 9 14:23:34 2013
New Revision: 192318
URL: http://llvm.org/viewvc/llvm-project?rev=192318&view=rev
Log:
Add error checking to 'cmd' buffer as it may not be available (ie. in the case of exec).
Modified:
lldb/trunk/source/Host/linux/Host.cpp
Modified: lldb/trunk/source/Host/linux/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/linux/Host.cpp?rev=192318&r1=192317&r2=192318&view=diff
==============================================================================
--- lldb/trunk/source/Host/linux/Host.cpp (original)
+++ lldb/trunk/source/Host/linux/Host.cpp Wed Oct 9 14:23:34 2013
@@ -403,18 +403,21 @@ GetProcessAndStatInfo (lldb::pid_t pid,
// Get the commond line used to start the process.
buf_sp = ReadProcPseudoFile(pid, "cmdline");
- // Grab Arg0 first.
+ // Grab Arg0 first, if there is one.
char *cmd = (char *)buf_sp->GetBytes();
- process_info.SetArg0(cmd);
-
- // Now process any remaining arguments.
- Args &info_args = process_info.GetArguments();
- char *next_arg = cmd + strlen(cmd) + 1;
- end_buf = cmd + buf_sp->GetByteSize();
- while (next_arg < end_buf && 0 != *next_arg)
+ if (cmd)
{
- info_args.AppendArgument(next_arg);
- next_arg += strlen(next_arg) + 1;
+ process_info.SetArg0(cmd);
+
+ // Now process any remaining arguments.
+ Args &info_args = process_info.GetArguments();
+ char *next_arg = cmd + strlen(cmd) + 1;
+ end_buf = cmd + buf_sp->GetByteSize();
+ while (next_arg < end_buf && 0 != *next_arg)
+ {
+ info_args.AppendArgument(next_arg);
+ next_arg += strlen(next_arg) + 1;
+ }
}
// Read /proc/$PID/stat to get our parent pid.
More information about the lldb-commits
mailing list