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>
This commit is contained in:
parent
90e40bd3d5
commit
ee26d83e98
1 changed files with 8 additions and 3 deletions
11
main.c
11
main.c
|
@ -47,10 +47,15 @@ static void
|
||||||
exec_self(int argc, char **argv)
|
exec_self(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
const char *cmd = rpc_exec_lookup(argv[0]);
|
const char *cmd;
|
||||||
char **args = calloc(argc + 1, sizeof(char *));
|
char **args;
|
||||||
|
|
||||||
if (!cmd || !args)
|
cmd = rpc_exec_lookup(argv[0]);
|
||||||
|
if (!cmd)
|
||||||
|
return;
|
||||||
|
|
||||||
|
args = calloc(argc + 1, sizeof(char *));
|
||||||
|
if (!args)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < argc; i++)
|
for (i = 0; i < argc; i++)
|
||||||
|
|
Loading…
Reference in a new issue