mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-08 21:06:48 +00:00
Fix the memory leak on large heap slot dealloc
This commit is contained in:
parent
3a1314296d
commit
d3e4f175cd
@ -116,6 +116,8 @@ impl<M: AnyFrameMeta> Segment<M> {
|
||||
/// It could be manually forgotten by [`core::mem::forget`],
|
||||
/// [`ManuallyDrop`], or [`Self::into_raw`].
|
||||
pub(crate) unsafe fn from_raw(range: Range<Paddr>) -> Self {
|
||||
debug_assert_eq!(range.start % PAGE_SIZE, 0);
|
||||
debug_assert_eq!(range.end % PAGE_SIZE, 0);
|
||||
Self {
|
||||
range,
|
||||
_marker: core::marker::PhantomData,
|
||||
|
@ -116,8 +116,7 @@ impl HeapSlot {
|
||||
|
||||
debug_assert_eq!(size % PAGE_SIZE, 0);
|
||||
debug_assert_eq!(self.paddr() % PAGE_SIZE, 0);
|
||||
let nframes = size / PAGE_SIZE;
|
||||
let range = self.paddr()..self.paddr() + nframes;
|
||||
let range = self.paddr()..self.paddr() + size;
|
||||
|
||||
// SAFETY: The segment was once forgotten when allocated.
|
||||
drop(unsafe { Segment::<LargeAllocFrameMeta>::from_raw(range) });
|
||||
|
Loading…
x
Reference in New Issue
Block a user