diff options
author | Alyssa Ross <hi@alyssa.is> | 2021-03-21 14:51:17 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2021-03-21 19:35:11 +0000 |
commit | dda096918ec16260b3e822c255521b79eaf876a4 (patch) | |
tree | 53e9888d1e2a6a7198558b7f9855d17097462529 | |
parent | 20a27f13713bb1c7be9bd82ac659e346f5384a51 (diff) | |
download | ucspi-vsock-dda096918ec16260b3e822c255521b79eaf876a4.tar ucspi-vsock-dda096918ec16260b3e822c255521b79eaf876a4.tar.gz ucspi-vsock-dda096918ec16260b3e822c255521b79eaf876a4.tar.bz2 ucspi-vsock-dda096918ec16260b3e822c255521b79eaf876a4.tar.lz ucspi-vsock-dda096918ec16260b3e822c255521b79eaf876a4.tar.xz ucspi-vsock-dda096918ec16260b3e822c255521b79eaf876a4.tar.zst ucspi-vsock-dda096918ec16260b3e822c255521b79eaf876a4.zip |
exec: free argv if exec fails
Identified by clang-tidy: exec.c:21:2: warning: Potential leak of memory pointed to by 'argv' [clang-analyzer-unix.Malloc] return execvp(file, argv); ^ exec.c:15:16: note: Memory is allocated char **argv = calloc(argz_count(argz, len) + 1, sizeof(char *)); ^ exec.c:16:6: note: Assuming 'argv' is non-null if (!argv) ^ exec.c:16:2: note: Taking false branch if (!argv) ^ exec.c:21:2: note: Potential leak of memory pointed to by 'argv' return execvp(file, argv); Message-Id: <20210321145118.27783-1-hi@alyssa.is> Reviewed-by: Cole Helbling <cole.e.helbling@outlook.com>
-rw-r--r-- | exec.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/exec.c b/exec.c index cc55200..75b1980 100644 --- a/exec.c +++ b/exec.c @@ -18,5 +18,8 @@ int execzp(const char *file, const char *argz, size_t len) argz_extract(argz, len, argv); - return execvp(file, argv); + execvp(file, argv); + + free(argv); + return -1; } |