Re: [PATCH] Fix broken sha1 locking

From: Linus Torvalds <>
Date: 2006-09-20 08:10:58
On Tue, 19 Sep 2006, Petr Baudis wrote:
> lock_ref_sha1_basic() never strdup()s ref (at least the reference used
> for git_path() later).

Ahh. So how did that ever work? Even in the current "master" branch, we 
call "resolve_ref()", which calls "git_path()", and historically we only 
had a single buffer..

So we're doing

	lock_ref_sha1_basic(git_path("refs/%s", ref),...

with that single buffer, and we _do_ do "xstrdup(path)" in between.

[ looks.. ]


We re-assign the "path" to point to the result value of the resolve_ref(), 
and so we do re-use the buffer, but we apparently never have any 
overlapping use. The packed-ref changes make us need pathnames in the 
middle, which we didn't use to do.

I do agree that we tend to use too many static buffers there. The static 
buffers are fine for the low-level functions ("mkpath()" and 
"git_path()"), but once they start getting passed around as arguments to 
other functions, they should be xstrdup'd or something.

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at
Received on Wed Sep 20 08:11:25 2006

This archive was generated by hypermail 2.1.8 : 2006-09-20 08:15:07 EST