瀏覽代碼

Merge pull request #2194 from mifreundorfer/fix-scratch-allocator

Handle freeing nil in scratch allocator
Jeroen van Rijn 2 年之前
父節點
當前提交
98a086b91b
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      core/mem/allocators.odin

+ 3 - 0
core/mem/allocators.odin

@@ -217,6 +217,9 @@ scratch_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode,
 		return ptr, err
 		return ptr, err
 
 
 	case .Free:
 	case .Free:
+		if old_memory == nil {
+			return nil, nil
+		}
 		start := uintptr(raw_data(s.data))
 		start := uintptr(raw_data(s.data))
 		end := start + uintptr(len(s.data))
 		end := start + uintptr(len(s.data))
 		old_ptr := uintptr(old_memory)
 		old_ptr := uintptr(old_memory)