diff --git a/src/pool.c b/src/pool.c index a2264f1..e9cd234 100644 --- a/src/pool.c +++ b/src/pool.c @@ -19,7 +19,8 @@ APool *apool_create_ex(Allocator *allocator, U32 n_elements, U32 element_size, U pool->start = NULL; if (size != APOOL_AUTOGROW) { - U32 total_size = n_elements * size; // Note(nos): guard against unreasonable sizes + Assert(n_elements <= U32_Max / size ); + U32 total_size = n_elements * size; U8 * start = allocator_push(allocator, total_size, align); for (U32 i = 0; i < total_size; i += size) { APoolElement *element = (APoolElement *)&start[i]; @@ -47,6 +48,8 @@ void *apool_alloc(APool *pool) void apool_free(APool *pool, void *ptr) { if (ptr != NULL) { + Assert((U8 *)ptr >= pool->start); + APoolElement *element = (APoolElement *)ptr; element->next = pool->free_list; pool->free_list = element;