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

Re: Segmentation fault in git read-tree

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Mar 14, 2008, 04:37 UTC
Message-ID
<alpine.LFD.1.00.0803132136080.3557@woody.linux-foundation.org>
In-Reply-To
<alpine.LFD.1.00.0803132125280.3557@woody.linux-foundation.org>
On Thu, 13 Mar 2008, Linus Torvalds wrote:
> 
> Ok, I can reproduce this, I'm on it like a maggot on a two-week-dead baby 
> donkey.
Ok, that was embarrassing.
This should fix it. Spot the stupid stack corruption..
		Linus
---
 unpack-trees.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/unpack-trees.c b/unpack-trees.c
index be89d52..b62b054 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -8,6 +8,8 @@
 #include "progress.h"
 #include "refs.h"
 
+#define MAX_UNPACK_TREES 4
+
 static void add_entry(struct unpack_trees_options *o, struct cache_entry *ce,
 	unsigned int set, unsigned int clear)
 {
@@ -123,7 +125,7 @@ static int unpack_index_entry(struct cache_entry *ce, struct unpack_trees_option
 int traverse_trees_recursive(int n, unsigned long dirmask, unsigned long df_conflicts, struct name_entry *names, struct traverse_info *info)
 {
 	int i;
-	struct tree_desc t[3];
+	struct tree_desc t[MAX_UNPACK_TREES];
 	struct traverse_info newinfo;
 	struct name_entry *p;
 
@@ -327,7 +329,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
 {
 	static struct cache_entry *dfc;
 
-	if (len > 4)
+	if (len > MAX_UNPACK_TREES)
 		die("unpack_trees takes at most four trees");
 	memset(&state, 0, sizeof(state));
 	state.base_dir = "";
Previous: Linus TorvaldsNext: Junio C Hamano
Message 4 of 9 in “Segmentation fault git read-tree”
  1. Len BrownMar 14, 2008
  2. Linus TorvaldsMar 14, 2008
  3. Linus TorvaldsMar 14, 2008
  4. Linus TorvaldsMar 14, 2008
  5. Junio C HamanoMar 14, 2008
  6. Junio C HamanoMar 14, 2008
  7. Junio C HamanoMar 14, 2008
  8. Len BrownMar 14, 2008
  9. Linus TorvaldsMar 14, 2008

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.