aboutsummaryrefslogtreecommitdiff
path: root/builtin/describe.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2013-05-25 11:08:00 +0200
committerJunio C Hamano <gitster@pobox.com>2013-05-28 09:25:00 -0700
commit219a0f33cae0f164f4353b2171ecd4c08d5b7ced (patch)
tree60eeeb45670c12f12a70467ed62917b558c316e2 /builtin/describe.c
parent5e49f30c85ecacec98631462fa73f1148a01637c (diff)
downloadgit-219a0f33cae0f164f4353b2171ecd4c08d5b7ced.tar.gz
git-219a0f33cae0f164f4353b2171ecd4c08d5b7ced.tar.xz
describe: make own copy of refname
Do not retain a reference to the refname passed to the each_ref_fn callback get_name(), because there is no guarantee of the lifetimes of these names. Instead, make a local copy when needed. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/describe.c')
-rw-r--r--builtin/describe.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/builtin/describe.c b/builtin/describe.c
index 6636a68cd..3dc09eb8a 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -42,7 +42,7 @@ struct commit_name {
unsigned prio:2; /* annotated tag = 2, tag = 1, head = 0 */
unsigned name_checked:1;
unsigned char sha1[20];
- const char *path;
+ char *path;
};
static const char *prio_names[] = {
"head", "lightweight", "annotated",
@@ -126,12 +126,14 @@ static void add_to_known_names(const char *path,
} else {
e->next = NULL;
}
+ e->path = NULL;
}
e->tag = tag;
e->prio = prio;
e->name_checked = 0;
hashcpy(e->sha1, sha1);
- e->path = path;
+ free(e->path);
+ e->path = xstrdup(path);
}
}