aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2018-08-25 10:22:29 +0200
committerLukas Fleischer <lfleischer@calcurse.org>2018-08-25 10:22:29 +0200
commit5efc334c1b0e8640e20b123d31f6ea52e20f9c2f (patch)
tree4fc326fa853a187f0dfb34b86576ccce0c5f12dc
parent7f448ee8cd8e5031ccc48604af2857bde94b0bae (diff)
downloadcalcurse-5efc334c1b0e8640e20b123d31f6ea52e20f9c2f.tar.gz
calcurse-5efc334c1b0e8640e20b123d31f6ea52e20f9c2f.zip
Fix memory leak in run_hook()
Fixes GitHub issue #139. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
-rw-r--r--src/hooks.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/hooks.c b/src/hooks.c
index ef917e4..b34313c 100644
--- a/src/hooks.c
+++ b/src/hooks.c
@@ -40,7 +40,7 @@
int run_hook(const char *name)
{
- char *hook_path;
+ char *hook_path = NULL;
char const *arg[2];
int pid, ret = -127;
int prepare_wins = (ui_mode == UI_CURSES);
@@ -50,7 +50,7 @@ int run_hook(const char *name)
arg[1] = NULL;
if (!io_file_exists(hook_path))
- return 0;
+ goto cleanup;
if (prepare_wins)
wins_prepare_external();
@@ -64,5 +64,7 @@ int run_hook(const char *name)
if (prepare_wins)
wins_unprepare_external();
+cleanup:
+ mem_free(hook_path);
return ret;
}