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

[PATCH] shallow.c: Don't free unallocated slabs

From
ASAli Utku Selen <auselen@gmail.com>
Date
Sep 30, 2019, 23:33 UTC
Message-ID
<20190930233310.19287-1-auselen@gmail.com>
Fix possible segfault when cloning a submodule shallow.
Signed-off-by: Ali Utku Selen <auselen@gmail.com>
---
It is possible to have unallocated slabs in shallow.c's commit_depth
for a shallow submodule with many commits.

Easiest way to reproduce this I found was changing COMMIT_SLAB_SIZE to 32 and run t7406-submodule-update.sh. Segfault happens in case 50: "submodule update clone shallow submodule outside of depth"

 shallow.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/shallow.c b/shallow.c
index 5fa2b15d37..c33ab94bd7 100644
--- a/shallow.c
+++ b/shallow.c
@@ -156,6 +156,8 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth,
 	for (i = 0; i < depths.slab_count; i++) {
 		int j;
 
+		if (!depths.slab[i])
+			continue;
 		for (j = 0; j < depths.slab_size; j++)
 			free(depths.slab[i][j]);
 	}
-- 
2.17.1
Next: Jeff King
Message 1 of 3 in “shallow.c: Don't free unallocated slabs”
  1. shallow.c: Don't free unallocated slabsAli Utku Selen, Sep 30, 2019
  2. Jeff KingOct 1, 2019
  3. Junio C HamanoOct 2, 2019

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.