From c4f6e973d952fa626e6c8d201ae7be91bdf72c67 Mon Sep 17 00:00:00 2001 From: Feoramund <161657516+Feoramund@users.noreply.github.com> Date: Sat, 14 Jun 2025 08:30:51 -0400 Subject: [PATCH] mem: Don't change `Scratch_Allocator`'s backup allocator The backup allocator is set at `init` and must stay the same for the lifetime of the Scratch allocator, as this allocator is used to free all `leaked_allocations`. Changing it could lead to a situation where the wrong allocator is used to free a leaked allocation. --- core/mem/allocators.odin | 4 ---- 1 file changed, 4 deletions(-) diff --git a/core/mem/allocators.odin b/core/mem/allocators.odin index bcc9e21df..90a5c4943 100644 --- a/core/mem/allocators.odin +++ b/core/mem/allocators.odin @@ -541,10 +541,6 @@ scratch_alloc_bytes_non_zeroed :: proc( } else { // NOTE: No need to use `aligned_size` here, as the backup allocator will handle alignment for us. a := s.backup_allocator - if a.procedure == nil { - a = context.allocator - s.backup_allocator = a - } ptr, err := alloc_bytes_non_zeroed(size, alignment, a, loc) if err != nil { return ptr, err