revision: note the lack of free() in simplify_merges()
Among the three similar-looking loops that walk singly linked commit_list, the first one is only peeking and the same list is later used for real work. Leave a comment not to mistakenly free its elements there. Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
a52f007113
commit
ab9d75a8d7
23
revision.c
23
revision.c
|
@ -2015,23 +2015,31 @@ static struct commit_list **simplify_one(struct rev_info *revs, struct commit *c
|
||||||
|
|
||||||
static void simplify_merges(struct rev_info *revs)
|
static void simplify_merges(struct rev_info *revs)
|
||||||
{
|
{
|
||||||
struct commit_list *list;
|
struct commit_list *list, *next;
|
||||||
struct commit_list *yet_to_do, **tail;
|
struct commit_list *yet_to_do, **tail;
|
||||||
|
struct commit *commit;
|
||||||
|
|
||||||
if (!revs->prune)
|
if (!revs->prune)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* feed the list reversed */
|
/* feed the list reversed */
|
||||||
yet_to_do = NULL;
|
yet_to_do = NULL;
|
||||||
for (list = revs->commits; list; list = list->next)
|
for (list = revs->commits; list; list = next) {
|
||||||
commit_list_insert(list->item, &yet_to_do);
|
commit = list->item;
|
||||||
|
next = list->next;
|
||||||
|
/*
|
||||||
|
* Do not free(list) here yet; the original list
|
||||||
|
* is used later in this function.
|
||||||
|
*/
|
||||||
|
commit_list_insert(commit, &yet_to_do);
|
||||||
|
}
|
||||||
while (yet_to_do) {
|
while (yet_to_do) {
|
||||||
list = yet_to_do;
|
list = yet_to_do;
|
||||||
yet_to_do = NULL;
|
yet_to_do = NULL;
|
||||||
tail = &yet_to_do;
|
tail = &yet_to_do;
|
||||||
while (list) {
|
while (list) {
|
||||||
struct commit *commit = list->item;
|
commit = list->item;
|
||||||
struct commit_list *next = list->next;
|
next = list->next;
|
||||||
free(list);
|
free(list);
|
||||||
list = next;
|
list = next;
|
||||||
tail = simplify_one(revs, commit, tail);
|
tail = simplify_one(revs, commit, tail);
|
||||||
|
@ -2043,9 +2051,10 @@ static void simplify_merges(struct rev_info *revs)
|
||||||
revs->commits = NULL;
|
revs->commits = NULL;
|
||||||
tail = &revs->commits;
|
tail = &revs->commits;
|
||||||
while (list) {
|
while (list) {
|
||||||
struct commit *commit = list->item;
|
|
||||||
struct commit_list *next = list->next;
|
|
||||||
struct merge_simplify_state *st;
|
struct merge_simplify_state *st;
|
||||||
|
|
||||||
|
commit = list->item;
|
||||||
|
next = list->next;
|
||||||
free(list);
|
free(list);
|
||||||
list = next;
|
list = next;
|
||||||
st = locate_simplify_state(revs, commit);
|
st = locate_simplify_state(revs, commit);
|
||||||
|
|
Loading…
Reference in New Issue