@matheusbsbs / matheus-bagliano / commits / 639ca54972
Fork 0

fix diff-delta bad memory access

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> Acked-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Nicolas Pitre committed May 10, 2006 at 12:26 UTC 639ca5497279607665847f2e3a11064441a8f2a6
1 file changed -5
diff-delta.c
-5
@@ -199,7 +199,6 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)
199 entry->next = hash[i];
200 hash[i] = entry++;
201 hash_count[i]++;
202 - entries--;
202 }
203 }
204
@@ -230,10 +229,6 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)
229 }
230 free(hash_count);
231
233 - /* If we didn't use all hash entries, free the unused memory. */
234 - if (entries)
235 - index = realloc(index, memsize - entries * sizeof(*entry));
236 -
232 return index;
233 }
234