From 5eabaaaabb7b7eb179a2edb7c30987d6be53f60b Mon Sep 17 00:00:00 2001 From: Tedlion Date: Thu, 29 Jan 2026 16:09:31 +0800 Subject: [PATCH] Fix an UB of comparing pointers The same UB with the one in heap_4.c. --- portable/MemMang/heap_5.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/portable/MemMang/heap_5.c b/portable/MemMang/heap_5.c index bf321304f..d86a6e9a5 100644 --- a/portable/MemMang/heap_5.c +++ b/portable/MemMang/heap_5.c @@ -489,7 +489,8 @@ static void prvInsertBlockIntoFreeList( BlockLink_t * pxBlockToInsert ) /* PRIVI /* Iterate through the list until a block is found that has a higher address * than the block being inserted. */ - for( pxIterator = &xStart; heapPROTECT_BLOCK_POINTER( pxIterator->pxNextFreeBlock ) < pxBlockToInsert; pxIterator = heapPROTECT_BLOCK_POINTER( pxIterator->pxNextFreeBlock ) ) + for( pxIterator = &xStart; ( portPOINTER_SIZE_TYPE ) heapPROTECT_BLOCK_POINTER( pxIterator->pxNextFreeBlock ) < ( portPOINTER_SIZE_TYPE ) pxBlockToInsert; + pxIterator = heapPROTECT_BLOCK_POINTER( pxIterator->pxNextFreeBlock ) ) { /* Nothing to do here, just iterate to the right position. */ }