mirror of
https://github.com/git/git.git
synced 2026-03-31 03:50:10 +02:00
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 <johannes.schindelin@gmx.de>
This commit is contained in:
2
refs.c
2
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;
|
||||
|
||||
Reference in New Issue
Block a user