You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/11/02 02:27:58 UTC
[incubator-nuttx] branch master updated: mm: fix realloc overwrite
memcpy when use a new block
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 3615592 mm: fix realloc overwrite memcpy when use a new block
3615592 is described below
commit 3615592e82a1083dbe8c65ac4154369f0aff473e
Author: ligd <li...@xiaomi.com>
AuthorDate: Tue Oct 26 16:10:39 2021 +0800
mm: fix realloc overwrite memcpy when use a new block
Signed-off-by: ligd <li...@xiaomi.com>
---
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 093446e..bfaf2e6 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);
}