From 3615592e82a1083dbe8c65ac4154369f0aff473e Mon Sep 17 00:00:00 2001 From: ligd Date: Tue, 26 Oct 2021 16:10:39 +0800 Subject: [PATCH] mm: fix realloc overwrite memcpy when use a new block Signed-off-by: ligd --- mm/mm_heap/mm_realloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/mm_heap/mm_realloc.c b/mm/mm_heap/mm_realloc.c index 093446efa1..bfaf2e6b46 100644 --- a/mm/mm_heap/mm_realloc.c +++ b/mm/mm_heap/mm_realloc.c @@ -355,7 +355,7 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem, newmem = (FAR void *)mm_malloc(heap, size); if (newmem) { - memcpy(newmem, oldmem, oldsize); + memcpy(newmem, oldmem, oldsize - SIZEOF_MM_ALLOCNODE); mm_free(heap, oldmem); }