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

[PATCH] pack-redundant: fix memory leak when open_pack_index() fails

From
Sahitya Chandra <sahityajb@gmail.com>
Date
Feb 21, 2026, 10:38 UTC
Message-ID
<20260221103900.41740-1-sahityajb@gmail.com>

In add_pack(), we allocate l.remaining_objects with llist_init() before calling open_pack_index(). If open_pack_index() fails we return NULL without freeing the allocated list, leaking the memory.

Fix by calling llist_free(l.remaining_objects) on the error path before returning.

Signed-off-by: Sahitya Chandra <sahityajb@gmail.com>
---
 builtin/pack-redundant.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c
index e4ecf774ca..86749bb7e7 100644
--- a/builtin/pack-redundant.c
+++ b/builtin/pack-redundant.c
@@ -546,8 +546,10 @@ static struct pack_list * add_pack(struct packed_git *p)
 	l.pack = p;
 	llist_init(&l.remaining_objects);
 
-	if (open_pack_index(p))
+	if (open_pack_index(p)) {
+		llist_free(l.remaining_objects);
 		return NULL;
+	}
 
 	base = p->index_data;
 	base += 256 * 4 + ((p->index_version < 2) ? 4 : 8);
-- 
2.43.0
Next: Patrick Steinhardt
Message 1 of 2 in “pack-redundant: fix memory leak when open_pack_index() fails”
  1. pack-redundant: fix memory leak when open_pack_index() failsSahitya Chandra, Feb 21, 2026
  2. Patrick SteinhardtFeb 24, 2026

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.