Re: [PATCH/RFC v3 2/6] reflog: refactor log open+mmap
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jan 17, 2009, 05:40 UTC
- Message-ID
- <alpine.DEB.1.00.0901170636280.3586@pacific.mpi-cbg.de>
- In-Reply-To
- <1232163011-20088-3-git-send-email-trast@student.ethz.ch>
Hi,
On Sat, 17 Jan 2009, Thomas Rast wrote:
Show 7 quoted lines
> +static char *open_reflog(const char *ref, size_t *mapsz, const char **logfile)
> +{
> + struct stat st;
> + int logfd;
> + char *map;
> +
> + *logfile = git_path("logs/%s", ref);That is dangerous. git_path() returns a pointer to a static buffer. Before your patch, logfile was a local variable, and one could be relatively sure that git_path() was not called during the lifetime. Now the lifetime of logfile is no longer as clear-cut, and it is much easier to overlook that git_path() must not be called while logfile holds a reference to its static buffer.
Ciao, Dscho