mirror of
https://github.com/git/git
synced 2024-08-27 19:49:21 +00:00
Merge branch 'rs/name-rev-fix-free-after-use' into maint
Regression fix for 2.36 where "git name-rev" started to sometimes reference strings after they are freed. This fixes a regression in 2.36 and is slate to go to 2.36.1 source: <340c8810-d912-7b18-d46e-a9d43f20216a@web.de> * rs/name-rev-fix-free-after-use: Revert "name-rev: release unused name strings"
This commit is contained in:
commit
ee12682367
|
@ -18,7 +18,7 @@
|
||||||
#define CUTOFF_DATE_SLOP 86400
|
#define CUTOFF_DATE_SLOP 86400
|
||||||
|
|
||||||
struct rev_name {
|
struct rev_name {
|
||||||
char *tip_name;
|
const char *tip_name;
|
||||||
timestamp_t taggerdate;
|
timestamp_t taggerdate;
|
||||||
int generation;
|
int generation;
|
||||||
int distance;
|
int distance;
|
||||||
|
@ -84,7 +84,7 @@ static int commit_is_before_cutoff(struct commit *commit)
|
||||||
|
|
||||||
static int is_valid_rev_name(const struct rev_name *name)
|
static int is_valid_rev_name(const struct rev_name *name)
|
||||||
{
|
{
|
||||||
return name && (name->generation || name->tip_name);
|
return name && name->tip_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct rev_name *get_commit_rev_name(const struct commit *commit)
|
static struct rev_name *get_commit_rev_name(const struct commit *commit)
|
||||||
|
@ -146,20 +146,9 @@ static struct rev_name *create_or_update_name(struct commit *commit,
|
||||||
{
|
{
|
||||||
struct rev_name *name = commit_rev_name_at(&rev_names, commit);
|
struct rev_name *name = commit_rev_name_at(&rev_names, commit);
|
||||||
|
|
||||||
if (is_valid_rev_name(name)) {
|
if (is_valid_rev_name(name) &&
|
||||||
if (!is_better_name(name, taggerdate, generation, distance, from_tag))
|
!is_better_name(name, taggerdate, generation, distance, from_tag))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/*
|
|
||||||
* This string might still be shared with ancestors
|
|
||||||
* (generation > 0). We can release it here regardless,
|
|
||||||
* because the new name that has just won will be better
|
|
||||||
* for them as well, so name_rev() will replace these
|
|
||||||
* stale pointers when it processes the parents.
|
|
||||||
*/
|
|
||||||
if (!name->generation)
|
|
||||||
free(name->tip_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
name->taggerdate = taggerdate;
|
name->taggerdate = taggerdate;
|
||||||
name->generation = generation;
|
name->generation = generation;
|
||||||
|
|
Loading…
Reference in a new issue