prevent accidental double free by checking tag before drop
This commit is contained in:
@@ -305,8 +305,10 @@ impl<T: ?Sized + ArenaAllocated> TypedArenaPtr<T> {
|
|||||||
|
|
||||||
impl<P, T: ?Sized + ArenaAllocated<Payload = ManuallyDrop<P>>> TypedArenaPtr<T> {
|
impl<P, T: ?Sized + ArenaAllocated<Payload = ManuallyDrop<P>>> TypedArenaPtr<T> {
|
||||||
pub fn drop_payload(&mut self) {
|
pub fn drop_payload(&mut self) {
|
||||||
self.set_tag(ArenaHeaderTag::Dropped);
|
if self.get_tag() != ArenaHeaderTag::Dropped {
|
||||||
unsafe { ManuallyDrop::drop(&mut *self.as_ptr()) }
|
self.set_tag(ArenaHeaderTag::Dropped);
|
||||||
|
unsafe { ManuallyDrop::drop(&mut *self.as_ptr()) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user