[PATCH] fix diff-delta bad memory access

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Junio C Hamano <junkio@...>
Cc: <git@...>, Randal L. Schwartz <merlyn@...>, Alex Riesen <raa.lkml@...>
Date: Wednesday, May 10, 2006 - 12:26 pm

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;
 }
 
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] fix diff-delta bad memory access, Nicolas Pitre, (Wed May 10, 12:26 pm)
Re: [PATCH] fix diff-delta bad memory access, Linus Torvalds, (Wed May 10, 1:00 pm)
Re: [PATCH] fix diff-delta bad memory access, Nicolas Pitre, (Wed May 10, 1:27 pm)
Re: [PATCH] fix diff-delta bad memory access, Linus Torvalds, (Wed May 10, 3:01 pm)
Re: [PATCH] fix diff-delta bad memory access, Nicolas Pitre, (Wed May 10, 3:43 pm)
Re: [PATCH] fix diff-delta bad memory access, Nicolas Pitre, (Wed May 10, 3:57 pm)
Re: [PATCH] fix diff-delta bad memory access, Linus Torvalds, (Wed May 10, 1:18 pm)