Kaynağa Gözat

mem: Guard against `Buddy_Allocator` overwriting metadata

Feoramund 2 ay önce
ebeveyn
işleme
4d4356e806
1 değiştirilmiş dosya ile 1 ekleme ve 0 silme
  1. 1 0
      core/mem/allocators.odin

+ 1 - 0
core/mem/allocators.odin

@@ -2328,6 +2328,7 @@ buddy_allocator_alloc_bytes_non_zeroed :: proc(b: ^Buddy_Allocator, size: uint)
 		}
 		found.is_free = false
 		data := ([^]byte)(found)[b.alignment:][:size]
+		assert(cast(uintptr)raw_data(data)+cast(uintptr)size < cast(uintptr)buddy_block_next(found), "Buddy_Allocator has made an allocation which overlaps a block header.")
 		// ensure_poisoned(data)
 		// sanitizer.address_unpoison(data)
 		return data, nil