git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] commit: fix memory leak in `reduce_heads()`

From
MÅMartin Ågren <martin.agren@gmail.com>
Date
Sep 20, 2017, 19:47 UTC
Message-ID
<1505936846-2195-3-git-send-email-martin.agren@gmail.com>

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
Next: Jeff King
Message 1 of 3 in “commit: fix memory leak in `reduce_heads()`”
  1. commit: fix memory leak in `reduce_heads()`Martin Ågren, Sep 20, 2017
  2. Jeff KingSep 20, 2017
  3. Jonathan NiederSep 20, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.