diff options
author | Matt Kopec <Matt.Kopec@intel.com> | 2013-10-09 19:23:34 +0000 |
---|---|---|
committer | Matt Kopec <Matt.Kopec@intel.com> | 2013-10-09 19:23:34 +0000 |
commit | dc7c73c604e08bf165504fd4dd7d71d0a4eb32a6 (patch) | |
tree | a5622e1dc3655f53b57c25b8be7059b0b23a700f /lldb/source/Host/linux/Host.cpp | |
parent | 20a1124ce58bd1d8c6b88cd19cea68f2e020f6ad (diff) | |
download | bcm5719-llvm-dc7c73c604e08bf165504fd4dd7d71d0a4eb32a6.tar.gz bcm5719-llvm-dc7c73c604e08bf165504fd4dd7d71d0a4eb32a6.zip |
Add error checking to 'cmd' buffer as it may not be available (ie. in the case of exec).
llvm-svn: 192318
Diffstat (limited to 'lldb/source/Host/linux/Host.cpp')
-rw-r--r-- | lldb/source/Host/linux/Host.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp index c23e8e44871..232f0c34845 100644 --- a/lldb/source/Host/linux/Host.cpp +++ b/lldb/source/Host/linux/Host.cpp @@ -403,18 +403,21 @@ GetProcessAndStatInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info, Proce // 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. |