summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYousong Zhou <yszhou4tech@gmail.com>2019-10-21 12:59:24 +0000
committerJo-Philipp Wich <jo@mein.io>2019-10-29 09:26:24 +0100
commitee26d83e983f93333b9d5147285cb902bb6cc737 (patch)
tree8a92539b3151ceca3aac9b2c75e8492611bbd0b8
parent90e40bd3d5b6d164be4c1f3583a13dc2f34d6563 (diff)
downloadrpcd-ee26d83e983f93333b9d5147285cb902bb6cc737.tar.gz
main: exec_self: make clang analyzer happy
Prevent a theoretical leak of the args memory when the executable path cannot be found. Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com> [fix whitespace, commit description] Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--main.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/main.c b/main.c
index 1db3241..9a177cf 100644
--- a/main.c
+++ b/main.c
@@ -47,10 +47,15 @@ static void
exec_self(int argc, char **argv)
{
int i;
- const char *cmd = rpc_exec_lookup(argv[0]);
- char **args = calloc(argc + 1, sizeof(char *));
+ const char *cmd;
+ char **args;
- if (!cmd || !args)
+ cmd = rpc_exec_lookup(argv[0]);
+ if (!cmd)
+ return;
+
+ args = calloc(argc + 1, sizeof(char *));
+ if (!args)
return;
for (i = 0; i < argc; i++)