Skip to contentSkip to conversation

commit: fix memory leak in `reduce_heads()`

PATCH Superseded Martin Ågren 3 participants 3 messages Sep 20, 2017

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 commit: fix memory leak in `reduce_heads()`

We don't free the temporary scratch space we use with remove_redundant(). Free it similar to how we do it in get_merge_bases_many_0().

---
 commit.c | 1 +
 1 file changed, 1 insertion(+)
commit.c +1 -0
index 9062980..1e0e633 100644
@@ -1086,6 +1086,7 @@ struct commit_list *reduce_heads(struct commit_list *heads)
 	num_head = remove_redundant(array, num_head);
 	for (i = 0; i < num_head; i++)
 		tail = &commit_list_insert(array[i], tail)->next;
+	free(array);
 	return result;
 }
 
Signature · 1 line
2.14.1
#1 lore raw
Quoted 3 lines · Martin Ågren

We don't free the temporary scratch space we use with remove_redundant(). Free it similar to how we do it in get_merge_bases_many_0().

Yep, seems very straightforward, and there are no code paths where we wouldn't want this.

-Peff