1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-20 02:56:12 +02:00

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>
This commit is contained in:
Michael Haggerty 2013-05-25 11:08:02 +02:00 committed by Junio C Hamano
parent b87dbcc899
commit df835d3a0c

View File

@ -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++;