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 13:57:02-07:00
log1ec0261518a8a0e302ebba28c96c4956ba323ce7
tree2f9d3d60adda2c7573e81124285508b14a4671d2
parent5c13a4e54a3ce814be02b75ef2029ceda6192bab

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
...@@ -517,7 +517,11 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {...@@ -517,7 +517,11 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
517 second_free_stack_trace,517 second_free_stack_trace,
518 });518 });
519 if (new_size == 0) {519 if (new_size == 0) {
520 // Recoverable.520 // Recoverable. Restore self.total_requested_bytes if needed, as we
521 // don't return an error value so the errdefer above does not run.
522 if (config.enable_memory_limit) {
523 self.total_requested_bytes = prev_req_bytes;
524 }
521 return @as(usize, 0);525 return @as(usize, 0);
522 }526 }
523 @panic("Unrecoverable double free");527 @panic("Unrecoverable double free");