mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 12:59:04 +00:00
Fix general purpose allocator incorrectly modifying total_requested_bytes in some cases
This commit is contained in:
parent
58c8ad8ea8
commit
81890e30e2
@ -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");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user