We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 35f348c + c47e940 commit 26b8027Copy full SHA for 26b8027
src/util/piped_process.cpp
@@ -277,10 +277,10 @@ piped_processt::piped_processt(
277
dup2(pipe_output[1], STDOUT_FILENO);
278
dup2(pipe_output[1], STDERR_FILENO);
279
280
- // Create a char** for the arguments (all the contents of commandvec
281
- // except the first element, i.e. the command itself).
282
- char **args =
283
- 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 *)));
284
// Add all the arguments to the args array of char *.
285
unsigned long i = 0;
286
while(i < commandvec.size())
0 commit comments