diff options
author | Ulrich Drepper <drepper@redhat.com> | 2006-10-12 21:52:54 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2006-10-12 21:52:54 +0000 |
commit | 90a0991a65186a68adc8caeec97da7678434040c (patch) | |
tree | 046da9d513e185386b8f4ed054525786a882f28f /elf | |
parent | de932366d43aba9a74010f4fb8b8da2f89cf1249 (diff) | |
download | glibc-90a0991a65186a68adc8caeec97da7678434040c.tar glibc-90a0991a65186a68adc8caeec97da7678434040c.tar.gz glibc-90a0991a65186a68adc8caeec97da7678434040c.tar.bz2 glibc-90a0991a65186a68adc8caeec97da7678434040c.zip |
[BZ #3352]
2006-10-12 Richard Sandiford <richard@codesourcery.com>
[BZ #3352]
* elf/dl-minimal.c (realloc): Let malloc() return a new pointer,
and use memcpy() if it does.
Diffstat (limited to 'elf')
-rw-r--r-- | elf/dl-minimal.c | 7 |
1 files changed, 4 insertions, 3 deletions
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; } |