aboutsummaryrefslogtreecommitdiff
path: root/elf/dl-minimal.c
diff options
context:
space:
mode:
Diffstat (limited to 'elf/dl-minimal.c')
-rw-r--r--elf/dl-minimal.c7
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;
}