diff options
| author | dmitriy.gorevoy <dmitriy.gorevoy@pressfire.games> | 2024-12-23 09:25:18 +0100 |
|---|---|---|
| committer | dmitriy.gorevoy <dmitriy.gorevoy@pressfire.games> | 2024-12-23 09:25:18 +0100 |
| commit | e82a0c8fc7db1f3eaa50e147c1cc0a3d2d482d9a (patch) | |
| tree | c9a95ea4ac6f19ba7f1d635a7d4a36c094734f0e | |
| parent | 597fba7c31f5e927b0c7431444dad132352b4046 (diff) | |
Fixed crash in arena_free_all() for bootstrapped growing arenas.
When trying to set arena.curr_block.used = 0 after mem.zero() caused a crash because if the arena is bootstrapped its memory will be zeroed out after mem.zero() thus making arena.cur_block point to zero.
| -rw-r--r-- | core/mem/virtual/arena.odin | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/core/mem/virtual/arena.odin b/core/mem/virtual/arena.odin index 79407d80d..4a0fff241 100644 --- a/core/mem/virtual/arena.odin +++ b/core/mem/virtual/arena.odin @@ -204,8 +204,9 @@ arena_free_all :: proc(arena: ^Arena, loc := #caller_location) { } // Zero the first block's memory if arena.curr_block != nil { - mem.zero(arena.curr_block.base, int(arena.curr_block.used)) + curr_block_used := int(arena.curr_block.used) arena.curr_block.used = 0 + mem.zero(arena.curr_block.base, curr_block_used) } arena.total_used = 0 case .Static, .Buffer: |