| ... | @@ -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"); |