Re: [PATCH] Fix broken sha1 locking
- From
Linus Torvalds <torvalds@osdl.org>
- Date
- Sep 19, 2006, 22:10 UTC
- Message-ID
- <Pine.LNX.4.64.0609191501311.4388@g5.osdl.org>
- In-Reply-To
- <20060919212340.GC8259@pasky.or.cz>
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.. ]
Ahh.
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.
Linus