You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "xiaoxiang781216 (via GitHub)" <gi...@apache.org> on 2023/05/30 08:12:21 UTC
[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #9418: mempool:fix bug read out of bounds when realloc
xiaoxiang781216 commented on code in PR #9418:
URL: https://github.com/apache/nuttx/pull/9418#discussion_r1209889127
##########
mm/mm_heap/mm_realloc.c:
##########
@@ -87,13 +90,14 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem,
{
return newmem;
}
- else if (size <= CONFIG_MM_HEAP_MEMPOOL_THRESHOLD ||
- mempool_multiple_alloc_size(heap->mm_mpool, oldmem) >= 0)
+ else if ((blksize =
+ mempool_multiple_alloc_size(heap->mm_mpool, oldmem)) >= 0 ||
+ size <= CONFIG_MM_HEAP_MEMPOOL_THRESHOLD)
{
newmem = mm_malloc(heap, size);
if (newmem != NULL)
{
- memcpy(newmem, oldmem, size);
+ memcpy(newmem, oldmem, MIN(size, blksize));
Review Comment:
Done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org