From: Michael Brown Date: Thu, 22 May 2025 15:05:37 +0000 (+0100) Subject: [uheap] Prevent allocation of blocks with zero physical addresses X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e056041074b9ed625791d8a688ef8a8cd8e9f7fd;p=thirdparty%2Fipxe.git [uheap] Prevent allocation of blocks with zero physical addresses If the external heap ends up at the top of the system memory map then leave a gap after the heap to ensure that no block ends up being allocated with either a start or end address of zero, since this is frequently confusing to both code and humans. Signed-off-by: Michael Brown --- diff --git a/src/core/uheap.c b/src/core/uheap.c index 60efcf050..f5154a0d1 100644 --- a/src/core/uheap.c +++ b/src/core/uheap.c @@ -100,8 +100,8 @@ static void uheap_find ( void ) { DBGC ( &uheap, "UHEAP largest region is [%#08lx,%#08lx)\n", start, end ); - /* Align start and end addresses */ - after = ( end & ( UHEAP_ALIGN - 1 ) ); + /* Align start and end addresses, and prevent overflow to zero */ + after = ( end ? ( end & ( UHEAP_ALIGN - 1 ) ) : UHEAP_ALIGN ); before = ( ( -start ) & ( UHEAP_ALIGN - 1 ) ); strip = ( before + after ); if ( strip > size )