commit 81890e30e2d51577e6c79b3a620115b6fbbf2071 (tree) parent 58c8ad8ea8698807934cdd05df821d39499a9ab6 Author: Nathanaƫl Courant <nathanael.courant@inria.fr> Date: Mon, 7 Dec 2020 23:27:37 +0100 Fix general purpose allocator incorrectly modifying total_requested_bytes in some cases Diffstat:
| M | lib/std/heap/general_purpose_allocator.zig | | | 6 | +++++- |
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lib/std/heap/general_purpose_allocator.zig b/lib/std/heap/general_purpose_allocator.zig @@ -528,7 +528,11 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { second_free_stack_trace, }); if (new_size == 0) { - // Recoverable. + // Recoverable. Restore self.total_requested_bytes if needed, as we + // don't return an error value so the errdefer above does not run. + if (config.enable_memory_limit) { + self.total_requested_bytes = prev_req_bytes; + } return @as(usize, 0); } @panic("Unrecoverable double free");