Skip to content

Commit

Permalink
gpa: Fix GeneralPurposeAllocator crash when deallocating metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Frojdholm committed May 21, 2024
1 parent ae44e19 commit 8a57e09
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/std/heap/general_purpose_allocator.zig
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,11 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
}
}
// free retained metadata for small allocations
var empty_it = self.empty_buckets.inorderIterator();
while (empty_it.next()) |node| {
while (self.empty_buckets.getMin()) |node| {
// remove the node from the tree before destroying it
var entry = self.empty_buckets.getEntryForExisting(node);
entry.set(null);

var bucket = node.key;
if (config.never_unmap) {
// free page that was intentionally leaked by never_unmap
Expand Down

0 comments on commit 8a57e09

Please sign in to comment.