From f323a179d98cab0278e59b549d956ef5deeb9150 Mon Sep 17 00:00:00 2001 From: Michael Freundorfer Date: Mon, 14 Nov 2022 21:44:20 +0100 Subject: [PATCH] Handle freeing nil in scratch allocator --- core/mem/allocators.odin | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/mem/allocators.odin b/core/mem/allocators.odin index ae248e1f3..98db9eeb2 100644 --- a/core/mem/allocators.odin +++ b/core/mem/allocators.odin @@ -217,6 +217,9 @@ scratch_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode, return ptr, err case .Free: + if old_memory == nil { + return nil, nil + } start := uintptr(raw_data(s.data)) end := start + uintptr(len(s.data)) old_ptr := uintptr(old_memory)