Skip to content
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: 8 additions & 0 deletions libpromises/exec_tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@
bool GetExecOutput(const char *command, char **buffer, size_t *buffer_size, ShellType shell, OutputSelect output_select, int *ret_out)
/* Buffer initially contains whole exec string */
{
assert(buffer != NULL && *buffer != NULL);
assert(buffer_size != NULL && *buffer_size > 0);

/* Terminate up front: if the command produces no output the read loop
* below never writes to the buffer, and a caller that allocated it with
* malloc() would otherwise see stale heap data as command output. */
(*buffer)[0] = '\0';

FILE *pp;

if (shell == SHELL_TYPE_USE)
Expand Down
Loading