Browse Source

prevent potential segfaults when using large allocations from dynamic pool

Benjamin Findley 2 years ago
parent
commit
38e06f13d6
1 changed files with 1 additions and 0 deletions
  1. 1 0
      core/mem/allocators.odin

+ 1 - 0
core/mem/allocators.odin

@@ -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,