Commit 621bf820 authored by Feng Xiao's avatar Feng Xiao

Null-terminate C strings.

Change-Id: I85675bfcd7697bb058b9af475445a6bfdd7fd967
parent 973bec13
...@@ -143,8 +143,9 @@ class ForkPipeRunner : public google::protobuf::ConformanceTestRunner { ...@@ -143,8 +143,9 @@ class ForkPipeRunner : public google::protobuf::ConformanceTestRunner {
CHECK_SYSCALL(close(toproc_pipe_fd[1])); CHECK_SYSCALL(close(toproc_pipe_fd[1]));
CHECK_SYSCALL(close(fromproc_pipe_fd[0])); CHECK_SYSCALL(close(fromproc_pipe_fd[0]));
scoped_array<char> executable(new char[executable_.size()]); scoped_array<char> executable(new char[executable_.size() + 1]);
memcpy(executable.get(), executable_.c_str(), executable_.size()); memcpy(executable.get(), executable_.c_str(), executable_.size());
executable[executable_.size()] = '\0';
char *const argv[] = {executable.get(), NULL}; char *const argv[] = {executable.get(), NULL};
CHECK_SYSCALL(execv(executable.get(), argv)); // Never returns. CHECK_SYSCALL(execv(executable.get(), argv)); // Never returns.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment