Thread (25 messages) 25 messages, 3 authors, 2016-06-15

Re: [PATCH/RFC v3 2/6] reflog: refactor log open+mmap

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:45:58

Hi,

On Sat, 17 Jan 2009, Thomas Rast wrote:
+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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help