From 298d4c3fb2514cf152645118918e20ef79c0324a Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 11 Jun 2010 23:39:47 +0200 Subject: [PATCH] Do not use invalid reference to the heap One should never return from a function the address of data allocated on the heap in that function, because with the end of that function, the address range is freed for other purposes. Work around the thinko by making the buffer static. This is far from ideal, but a work-around. This fixes a regression introduced in 859c301(refs: split log_ref_write logic into log_ref_setup). Signed-off-by: Johannes Schindelin --- refs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/refs.c b/refs.c index 34366497b9..775f04f138 100644 --- a/refs.c +++ b/refs.c @@ -1265,7 +1265,7 @@ static int copy_msg(char *buf, const char *msg) int log_ref_setup(const char *ref_name, char **log_file) { int logfd, oflags = O_APPEND | O_WRONLY; - char logfile[PATH_MAX]; + static char logfile[PATH_MAX]; git_snpath(logfile, sizeof(logfile), "logs/%s", ref_name); *log_file = logfile;