summaryrefslogtreecommitdiff
path: root/revision.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2013-05-25 09:08:02 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-05-28 16:25:00 (GMT)
commitdf835d3a0c013b9ef912172663c7c58dad87164d (patch)
treec9b781db5c65aac0f3ecda6e10667e3e807577d8 /revision.c
parentb87dbcc89940edbf92cbab381001542a7cac3627 (diff)
downloadgit-df835d3a0c013b9ef912172663c7c58dad87164d.zip
git-df835d3a0c013b9ef912172663c7c58dad87164d.tar.gz
git-df835d3a0c013b9ef912172663c7c58dad87164d.tar.bz2
add_rev_cmdline(): make a copy of the name argument
Instead of assuming that the memory pointed to by the name argument will live forever, make a local copy of it before storing it in the ref_cmdline_info. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'revision.c')
-rw-r--r--revision.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/revision.c b/revision.c
index a67b615..25e424c 100644
--- a/revision.c
+++ b/revision.c
@@ -898,6 +898,10 @@ static int limit_list(struct rev_info *revs)
return 0;
}
+/*
+ * Add an entry to refs->cmdline with the specified information.
+ * *name is copied.
+ */
static void add_rev_cmdline(struct rev_info *revs,
struct object *item,
const char *name,
@@ -909,7 +913,7 @@ static void add_rev_cmdline(struct rev_info *revs,
ALLOC_GROW(info->rev, nr + 1, info->alloc);
info->rev[nr].item = item;
- info->rev[nr].name = name;
+ info->rev[nr].name = xstrdup(name);
info->rev[nr].whence = whence;
info->rev[nr].flags = flags;
info->nr++;