fix diff-delta bad memory access
authorNicolas Pitre <nico@cam.org>
Wed, 10 May 2006 16:26:08 +0000 (12:26 -0400)
committerJunio C Hamano <junkio@cox.net>
Wed, 10 May 2006 17:53:59 +0000 (10:53 -0700)
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>
diff-delta.c
index c61887518874d550f66d2d52bd7559d023fcb176..25a798d050c6319f3d524c9c605ab70ea35ae7a1 100644 (file)
@@ -199,7 +199,6 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)
                        entry->next = hash[i];
                        hash[i] = entry++;
                        hash_count[i]++;
-                       entries--;
                }
        }
 
@@ -230,10 +229,6 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)
        }
        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;
 }