git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] commit: fix memory leak in `reduce_heads()`
@ 2017-09-20 19:47 Martin Ågren
  2017-09-20 20:15 ` Jeff King
  2017-09-20 21:34 ` Jonathan Nieder
  0 siblings, 2 replies; 3+ messages in thread
From: Martin Ågren @ 2017-09-20 19:47 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

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()`.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
---
 commit.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/commit.c b/commit.c
index 9062980..1e0e633 100644
--- a/commit.c
+++ b/commit.c
@@ -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;
 }
 
-- 
2.14.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] commit: fix memory leak in `reduce_heads()`
  2017-09-20 19:47 [PATCH] commit: fix memory leak in `reduce_heads()` Martin Ågren
@ 2017-09-20 20:15 ` Jeff King
  2017-09-20 21:34 ` Jonathan Nieder
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff King @ 2017-09-20 20:15 UTC (permalink / raw)
  To: Martin Ågren; +Cc: git, Junio C Hamano

On Wed, Sep 20, 2017 at 09:47:25PM +0200, Martin Ågren wrote:

> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] commit: fix memory leak in `reduce_heads()`
  2017-09-20 19:47 [PATCH] commit: fix memory leak in `reduce_heads()` Martin Ågren
  2017-09-20 20:15 ` Jeff King
@ 2017-09-20 21:34 ` Jonathan Nieder
  1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Nieder @ 2017-09-20 21:34 UTC (permalink / raw)
  To: Martin Ågren; +Cc: git, Junio C Hamano

Martin Ågren wrote:

> 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()`.
>
> Signed-off-by: Martin Ågren <martin.agren@gmail.com>
> ---
>  commit.c | 1 +
>  1 file changed, 1 insertion(+)

Good catch.  Thanks.

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-09-20 21:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-20 19:47 [PATCH] commit: fix memory leak in `reduce_heads()` Martin Ågren
2017-09-20 20:15 ` Jeff King
2017-09-20 21:34 ` Jonathan Nieder

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).