From 03f2c7731b59de75357730bc511ffa8847e1fb81 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Mon, 10 Aug 2015 05:37:45 -0400 Subject: find_hook: keep our own static buffer The find_hook function returns the results of git_path, which is a static buffer shared by other path-related calls. Returning such a buffer is slightly dangerous, because it can be overwritten by seemingly unrelated functions. Let's at least keep our _own_ static buffer, so you can only get in trouble by calling find_hook in quick succession, which is less likely to happen and more obvious to notice. While we're at it, let's add some documentation of the function's limitations. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- run-command.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'run-command.h') diff --git a/run-command.h b/run-command.h index 1103805af1..5b4425a3cb 100644 --- a/run-command.h +++ b/run-command.h @@ -52,6 +52,11 @@ int start_command(struct child_process *); int finish_command(struct child_process *); int run_command(struct child_process *); +/* + * Returns the path to the hook file, or NULL if the hook is missing + * or disabled. Note that this points to static storage that will be + * overwritten by further calls to find_hook and run_hook_*. + */ extern const char *find_hook(const char *name); LAST_ARG_MUST_BE_NULL extern int run_hook_le(const char *const *env, const char *name, ...); -- cgit v1.2.1