{"thread":{"id":"46792","subject":"[PATCH] commit: fix memory leak in `reduce_heads()`","startedAt":"2017-09-20T19:48:20Z","lastAt":"2017-09-20T21:34:26Z","messageCount":3,"participants":["Martin Ågren","Jeff King","Jonathan Nieder"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"328490","messageId":"1505936846-2195-3-git-send-email-martin.agren@gmail.com","threadId":"46792","inReplyTo":null,"subject":"[PATCH] commit: fix memory leak in `reduce_heads()`","fromName":"Martin Ågren","fromEmail":"martin.agren@gmail.com","sentAt":"2017-09-20T19:47:25Z","receivedAt":"2017-09-20T19:48:20Z","isPatch":true,"sender":{"key":"martin.agren@gmail.com","avatar":null},"body":"We don't free the temporary scratch space we use with\n`remove_redundant()`. Free it similar to how we do it in\n`get_merge_bases_many_0()`.\n\nSigned-off-by: Martin Ågren <martin.agren@gmail.com>\n---\n commit.c | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/commit.c b/commit.c\nindex 9062980..1e0e633 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -1086,6 +1086,7 @@ struct commit_list *reduce_heads(struct commit_list *heads)\n \tnum_head = remove_redundant(array, num_head);\n \tfor (i = 0; i < num_head; i++)\n \t\ttail = &commit_list_insert(array[i], tail)->next;\n+\tfree(array);\n \treturn result;\n }\n \n-- \n2.14.1\n\n"},{"id":"328497","messageId":"20170920201532.paynyzq7ln7cadqc@sigill.intra.peff.net","threadId":"46792","inReplyTo":"1505936846-2195-3-git-send-email-martin.agren@gmail.com","subject":"Re: [PATCH] commit: fix memory leak in `reduce_heads()`","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-09-20T20:15:32Z","receivedAt":"2017-09-20T20:15:38Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Sep 20, 2017 at 09:47:25PM +0200, Martin Ågren wrote:\n\n> We don't free the temporary scratch space we use with\n> `remove_redundant()`. Free it similar to how we do it in\n> `get_merge_bases_many_0()`.\n\nYep, seems very straightforward, and there are no code paths where we\nwouldn't want this.\n\n-Peff\n"},{"id":"328505","messageId":"20170920213417.GG27425@aiede.mtv.corp.google.com","threadId":"46792","inReplyTo":"1505936846-2195-3-git-send-email-martin.agren@gmail.com","subject":"Re: [PATCH] commit: fix memory leak in `reduce_heads()`","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2017-09-20T21:34:17Z","receivedAt":"2017-09-20T21:34:26Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Martin Ågren wrote:\n\n> We don't free the temporary scratch space we use with\n> `remove_redundant()`. Free it similar to how we do it in\n> `get_merge_bases_many_0()`.\n>\n> Signed-off-by: Martin Ågren <martin.agren@gmail.com>\n> ---\n>  commit.c | 1 +\n>  1 file changed, 1 insertion(+)\n\nGood catch.  Thanks.\n\nReviewed-by: Jonathan Nieder <jrnieder@gmail.com>\n"}]}