From 5efc334c1b0e8640e20b123d31f6ea52e20f9c2f Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Sat, 25 Aug 2018 10:22:29 +0200 Subject: Fix memory leak in run_hook() Fixes GitHub issue #139. Signed-off-by: Lukas Fleischer --- src/hooks.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') 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; } -- cgit v1.2.3-70-g09d2