fix leak of slaps with dropped payload

This commit is contained in:
Bennet Bleßmann
2024-07-07 15:51:22 +02:00
parent 689632b51c
commit 5d03be4b09
2 changed files with 27 additions and 6 deletions

View File

@@ -470,7 +470,16 @@ macro_rules! arena_allocated_impl_for_stream {
unsafe fn dealloc(ptr: std::ptr::NonNull<TypedAllocSlab<Self>>) {
let mut slab = unsafe { Box::from_raw(ptr.as_ptr()) };
unsafe { std::mem::ManuallyDrop::drop(slab.payload()) };
match slab.tag() {
ArenaHeaderTag::$stream_tag => {
unsafe { std::mem::ManuallyDrop::drop(slab.payload()) };
}
ArenaHeaderTag::Dropped => {}
_ => {
unreachable!()
}
}
drop(slab);
}
}