summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--payloads/libpayload/libc/malloc.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/payloads/libpayload/libc/malloc.c b/payloads/libpayload/libc/malloc.c
index 1fdb59e9b1..f2a54a70c8 100644
--- a/payloads/libpayload/libc/malloc.c
+++ b/payloads/libpayload/libc/malloc.c
@@ -310,8 +310,9 @@ void *realloc(void *ptr, size_t size)
if (ret == NULL || ret == ptr)
return ret;
- /* Copy the memory to the new location. */
- memcpy(ret, ptr, osize > size ? size : osize);
+ /* Move the memory to the new location. Might be before the old location
+ and overlap since the free() above includes a _consolidate(). */
+ memmove(ret, ptr, osize > size ? size : osize);
return ret;
}