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

[PATCH] sha1_file: fix delta_stack memory leak in unpack_entry

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Feb 20, 2014, 23:47 UTC
Message-ID
<1392940067-4830-1-git-send-email-pclouds@gmail.com>

This delta_stack array can grow to any length depending on the actual delta chain, but we forget to free it. Normally it does not matter because we use small_delta_stack[] from stack and small_delta_stack can hold 64-delta chains, more than standard --depth=50 in pack-objects.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Found when trying to see if making some objects loose at this phase
 could help git-blame and how many objects will be loosened. Gotta go
 soon, didn't really test it, but I bet it'll work.
 sha1_file.c | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/sha1_file.c b/sha1_file.c
index 6e8c05d..57ab15d 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2289,6 +2289,10 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
 	*final_size = size;
 
 	unuse_pack(&w_curs);
+
+	if (delta_stack != small_delta_stack)
+		free(delta_stack);
+
 	return data;
 }
 
-- 
1.9.0.40.gaa8c3ea
Next: Jeff King
Message 1 of 5 in “sha1_file: fix delta_stack memory leak in unpack_entry”
  1. sha1_file: fix delta_stack memory leak in unpack_entryNguyễn Thái Ngọc Duy, Feb 20, 2014
  2. Jeff KingFeb 21, 2014
  3. Junio C HamanoFeb 21, 2014
  4. Jeff KingFeb 22, 2014
  5. Thomas RastFeb 22, 2014

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.