From 8aa5f3bba2d8355467733e74fbe576a04f099249 Mon Sep 17 00:00:00 2001 From: Cobus van Eeden <35851496+cobusve@users.noreply.github.com> Date: Sat, 5 Dec 2020 16:01:47 -0800 Subject: [PATCH] adjustments for consistency --- portable/MemMang/heap_2.c | 4 ++-- portable/MemMang/heap_4.c | 2 +- portable/MemMang/heap_5.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/portable/MemMang/heap_2.c b/portable/MemMang/heap_2.c index 1240a6b53..1eed436ce 100644 --- a/portable/MemMang/heap_2.c +++ b/portable/MemMang/heap_2.c @@ -138,7 +138,7 @@ void * pvPortMalloc( size_t xWantedSize ) { /* Ensure xWantedSize will never wrap after adjustment, even if we need * an alignment adjustment */ - if ( xWantedSize < ( SIZE_MAX - heapSTRUCT_SIZE - portBYTE_ALIGNMENT - 1) ) + if( ( xWantedSize > 0 ) && ( ( xWantedSize + xHeapStructSize ) > xWantedSize ) ) { xWantedSize += heapSTRUCT_SIZE; @@ -154,7 +154,7 @@ void * pvPortMalloc( size_t xWantedSize ) } } - if( xWantedSize > 0 ) + if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) ) { /* Blocks are stored in byte order - traverse the list from the start * (smallest) block until one of adequate size is found. */ diff --git a/portable/MemMang/heap_4.c b/portable/MemMang/heap_4.c index 8bdedf767..a86052c20 100644 --- a/portable/MemMang/heap_4.c +++ b/portable/MemMang/heap_4.c @@ -176,7 +176,7 @@ void * pvPortMalloc( size_t xWantedSize ) mtCOVERAGE_TEST_MARKER(); } - if( ( xWantedSize > 0 ) && ( xWantedSize < xFreeBytesRemaining ) ) + if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) ) { /* Traverse the list from the start (lowest address) block until * one of adequate size is found. */ diff --git a/portable/MemMang/heap_5.c b/portable/MemMang/heap_5.c index 4953237f0..c4d96cb44 100644 --- a/portable/MemMang/heap_5.c +++ b/portable/MemMang/heap_5.c @@ -179,7 +179,7 @@ void * pvPortMalloc( size_t xWantedSize ) xWantedSize = 0; } - if( ( xWantedSize > 0 ) && ( xWantedSize < xFreeBytesRemaining ) ) + if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) ) { /* Traverse the list from the start (lowest address) block until * one of adequate size is found. */