Skip to content

Piped process: fix off-by-one error #7738

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/util/piped_process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,10 @@ piped_processt::piped_processt(
dup2(pipe_output[1], STDOUT_FILENO);
dup2(pipe_output[1], STDERR_FILENO);

// Create a char** for the arguments (all the contents of commandvec
// except the first element, i.e. the command itself).
char **args =
reinterpret_cast<char **>(malloc((commandvec.size()) * sizeof(char *)));
// Create a char** for the arguments plus a NULL terminator (by convention,
// the first "argument" is the command itself)
char **args = reinterpret_cast<char **>(
malloc((commandvec.size() + 1) * sizeof(char *)));
// Add all the arguments to the args array of char *.
unsigned long i = 0;
while(i < commandvec.size())
Expand Down