|
From: Jeff King <peff <at> peff.net>
Subject: Re: [PATCH] for-each-ref: fix objectname:short bug Newsgroups: gmane.comp.version-control.git Date: 2010-08-26 22:15:36 GMT (1 year, 23 weeks, 5 days, 17 hours and 26 minutes ago)
On Thu, Aug 26, 2010 at 05:34:29PM -0400, Jay Soffian wrote:
> When objectname:short was introduced, it forgot to copy the result of
> find_unique_abbrev. Because the result of find_unique_abbrev is a
> pointer to static buffer, this resulted in the same value being
> substituted in for each ref.
Yuck. I can't believe neither Michael nor I noticed this on first
review.
> --- a/builtin/for-each-ref.c
> +++ b/builtin/for-each-ref.c
> @@ -228,7 +228,8 @@ static void grab_common_values(struct atom_value *val, int deref, struct object
> v->s = s;
> }
> else if (!strcmp(name, "objectname:short")) {
> - v->s = find_unique_abbrev(obj->sha1, DEFAULT_ABBREV);
> + v->s = xstrdup(find_unique_abbrev(obj->sha1,
> + DEFAULT_ABBREV));
Your fix looks correct. It obviously leaks, but then so does 99% of the
rest of for-each-ref.
-Peff
|
|