From 115099698abac2ae1473ad4670130291a430b636 Mon Sep 17 00:00:00 2001 From: obarthel Date: Sat, 9 Sep 2023 12:55:01 +0200 Subject: [PATCH] Added an assertion to verify that the first free chunk on the slab's list is really always available. --- library/stdlib_slab.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) mode change 100755 => 100644 library/stdlib_slab.c diff --git a/library/stdlib_slab.c b/library/stdlib_slab.c old mode 100755 new mode 100644 index fec09f3..99031b7 --- a/library/stdlib_slab.c +++ b/library/stdlib_slab.c @@ -417,8 +417,8 @@ __slab_allocate(size_t allocation_size) * padding added to make the first allocatable slab start on * a 64 bit boundary. */ - aligned_first_byte = ((ULONG)&new_sn[1] + MEM_BLOCKMASK) & ~MEM_BLOCKMASK; - + aligned_first_byte = (((ULONG)&new_sn[1]) + MEM_BLOCKMASK) & ~MEM_BLOCKMASK; + first_byte = (BYTE *)aligned_first_byte; last_byte = &first_byte[__slab_data.sd_StandardSlabSize - chunk_size]; @@ -446,6 +446,8 @@ __slab_allocate(size_t allocation_size) /* Grab the first free chunk (there has to be one). */ chunk = (struct SlabChunk *)RemHead((struct List *)&new_sn->sn_FreeList); + assert( chunk != NULL ); + /* Keep track of this chunk's parent slab. */ chunk->sc_ParentSlab = new_sn;