Merge pull request #2721 from Kartoffelsaft/dynamic-pool-alloc

Return .Invalid_Argument in pool allocator to avoid potential segfaults
This commit is contained in:
gingerBill
2023-08-16 12:02:21 +01:00
committed by GitHub

View File

@@ -749,6 +749,7 @@ dynamic_pool_alloc_bytes :: proc(p: ^Dynamic_Pool, bytes: int) -> ([]byte, Alloc
n := bytes
extra := p.alignment - (n % p.alignment)
n += extra
if n > p.block_size do return nil, .Invalid_Argument
if n >= p.out_band_size {
assert(p.block_allocator.procedure != nil)
memory, err := p.block_allocator.procedure(p.block_allocator.data, Allocator_Mode.Alloc,