mempool:fix bug read out of bounds when realloc

fix kasan report

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
anjiahao 2023-05-19 19:28:14 +08:00 committed by Xiang Xiao
parent f24ab22b76
commit 045b9ffd54

View File

@ -93,7 +93,7 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem,
newmem = mm_malloc(heap, size);
if (newmem != NULL)
{
memcpy(newmem, oldmem, size);
memcpy(newmem, oldmem, MIN(size, mm_malloc_size(heap, oldmem)));
mm_free(heap, oldmem);
}