From 90a0991a65186a68adc8caeec97da7678434040c Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 12 Oct 2006 21:52:54 +0000 Subject: [BZ #3352] 2006-10-12 Richard Sandiford [BZ #3352] * elf/dl-minimal.c (realloc): Let malloc() return a new pointer, and use memcpy() if it does. --- elf/dl-minimal.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'elf/dl-minimal.c') diff --git a/elf/dl-minimal.c b/elf/dl-minimal.c index 868d3bd2ed..44b8c3718b 100644 --- a/elf/dl-minimal.c +++ b/elf/dl-minimal.c @@ -128,13 +128,14 @@ free (void *ptr) void * weak_function realloc (void *ptr, size_t n) { - void *new; if (ptr == NULL) return malloc (n); assert (ptr == alloc_last_block); + size_t old_size = alloc_ptr - alloc_last_block; alloc_ptr = alloc_last_block; - new = malloc (n); - assert (new == ptr); + void *new = malloc (n); + if (new != ptr) + memcpy (new, ptr, old_size); return new; } -- cgit 1.4.1