| ... | @@ -528,7 +528,11 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { | ... | @@ -528,7 +528,11 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { |
| 528 | second_free_stack_trace, | 528 | second_free_stack_trace, |
| 529 | }); | 529 | }); |
| 530 | if (new_size == 0) { | 530 | 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 | } |
| 532 | return @as(usize, 0); | 536 | return @as(usize, 0); |
| 533 | } | 537 | } |
| 534 | @panic("Unrecoverable double free"); | 538 | @panic("Unrecoverable double free"); |