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

[PATCH] fix diff-delta bad memory access

From
Nicolas Pitre <nico@cam.org>
Date
May 10, 2006, 16:26 UTC
Message-ID
<Pine.LNX.4.64.0605101216360.24505@localhost.localdomain>

It cannot be assumed that the given buffer will never be moved when shrinking the allocated memory size with realloc(). So let's ignore that optimization for now.

This patch makes Electric Fence happy on Linux.
Signed-off-by: Nicolas Pitre <nico@cam.org>
---
I can't tell if that fixes it on BSD and Cygwin though.
diff --git a/Makefile b/Makefile
diff --git a/diff-delta.c b/diff-delta.c
index c618875..25a798d 100644
--- a/diff-delta.c
+++ b/diff-delta.c
@@ -199,7 +199,6 @@ struct delta_index * create_delta_index(
 			entry->next = hash[i];
 			hash[i] = entry++;
 			hash_count[i]++;
-			entries--;
 		}
 	}
 
@@ -230,10 +229,6 @@ struct delta_index * create_delta_index(
 	}
 	free(hash_count);
 
-	/* If we didn't use all hash entries, free the unused memory. */
-	if (entries)
-		index = realloc(index, memsize - entries * sizeof(*entry));
-
 	return index;
 }
 
Next: Linus Torvalds
Message 1 of 7 in “fix diff-delta bad memory access”
  1. fix diff-delta bad memory accessNicolas Pitre, May 10, 2006
  2. Linus TorvaldsMay 10, 2006
  3. Linus TorvaldsMay 10, 2006
  4. Nicolas PitreMay 10, 2006
  5. Linus TorvaldsMay 10, 2006
  6. Nicolas PitreMay 10, 2006
  7. Nicolas PitreMay 10, 2006

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.