summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2020-10-09 23:51:49 -0400
committerLukas Fleischer <lfleischer@calcurse.org>2020-10-11 09:59:37 -0400
commit1b40844aa3b7a94fd84533ed6ef78a5c5cbac5f1 (patch)
treec940256940f8228e50b306617bd1e9fe5800a994 /src
parent47fb9b740fcc0f050ada0418a473cdd660eb46cb (diff)
downloadcalcurse-1b40844aa3b7a94fd84533ed6ef78a5c5cbac5f1.tar.gz
calcurse-1b40844aa3b7a94fd84533ed6ef78a5c5cbac5f1.zip
Fix memory leak in run_hook()
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src')
-rw-r--r--src/hooks.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/hooks.c b/src/hooks.c
index 8fda0da..b4933af 100644
--- a/src/hooks.c
+++ b/src/hooks.c
@@ -41,15 +41,15 @@
int run_hook(const char *name)
{
- char *hook_cmd = NULL, *mesg;
+ char *hook_path = NULL, *hook_cmd = NULL, *mesg;
char const *arg[2];
int pid, ret = -127;
- asprintf(&hook_cmd, "%s/%s", path_hooks, name);
- if (!io_file_exists(hook_cmd))
+ asprintf(&hook_path, "%s/%s", path_hooks, name);
+ if (!io_file_exists(hook_path))
goto cleanup;
- asprintf(&hook_cmd, "%s <&- >&- 2>&-", hook_cmd);
+ asprintf(&hook_cmd, "%s <&- >&- 2>&-", hook_path);
arg[0] = hook_cmd;
arg[1] = NULL;
@@ -70,6 +70,7 @@ int run_hook(const char *name)
}
cleanup:
+ mem_free(hook_path);
mem_free(hook_cmd);
return ret;
}