authorgravatar for nathanael.courant@inria.frNathanaël Courant <nathanael.courant@inria.fr> 2020-12-07 23:27:37+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-12-08 15:53:34-05:00
log81890e30e2d51577e6c79b3a620115b6fbbf2071
tree06937163312d3133cfe448451e0890248758ecc6
parent58c8ad8ea8698807934cdd05df821d39499a9ab6

Fix general purpose allocator incorrectly modifying total_requested_bytes in some cases


1 files changed, 5 insertions(+), 1 deletions(-)

lib/std/heap/general_purpose_allocator.zig+5-1
......@@ -528,7 +528,11 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
528528 second_free_stack_trace,
529529 });
530530 if (new_size == 0) {
531 // Recoverable.
531 // Recoverable. Restore self.total_requested_bytes if needed, as we
532 // don't return an error value so the errdefer above does not run.
533 if (config.enable_memory_limit) {
534 self.total_requested_bytes = prev_req_bytes;
535 }
532536 return @as(usize, 0);
533537 }
534538 @panic("Unrecoverable double free");