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

[PATCH] Fix segfault in diff-delta.c when FLEX_ARRAY is 1

From
Pierre Habouzit <madcoder@debian.org>
Date
Dec 18, 2007, 01:39 UTC
Message-ID
<1197941997-11421-1-git-send-email-madcoder@debian.org>

aka don't do pointer arithmetics on structs that have a FLEX_ARRAY member, or you'll end up believing your array is 1 cell off its real address.

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
---
 diff-delta.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/diff-delta.c b/diff-delta.c
index 9e440a9..601b49e 100644
--- a/diff-delta.c
+++ b/diff-delta.c
@@ -264,7 +264,7 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)
 	index->src_size = bufsize;
 	index->hash_mask = hmask;
 
-	mem = index + 1;
+	mem = index->hash;
 	packed_hash = mem;
 	mem = packed_hash + (hsize+1);
 	packed_entry = mem;
-- 
1.5.4.rc0.1153.gb1b3d-dirty
Next: Pierre Habouzit
Message 1 of 7 in “Fix segfault in diff-delta.c when FLEX_ARRAY is 1”
  1. Fix segfault in diff-delta.c when FLEX_ARRAY is 1Pierre Habouzit, Dec 18, 2007
  2. Pierre HabouzitDec 18, 2007
  3. Linus TorvaldsDec 18, 2007
  4. Linus TorvaldsDec 18, 2007
  5. Junio C HamanoDec 18, 2007
  6. David KastrupDec 18, 2007
  7. Nicolas PitreDec 18, 2007

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.