From 782cf5a5e8c1b209ac5b85119e5a4a979b8e73b6 Mon Sep 17 00:00:00 2001 From: Erin Date: Thu, 17 Aug 2023 21:55:37 +0200 Subject: [PATCH] Fixed leakage --- hbvm/fuzz/fuzz_targets/vm.rs | 2 ++ hbvm/src/main.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/hbvm/fuzz/fuzz_targets/vm.rs b/hbvm/fuzz/fuzz_targets/vm.rs index 2c368db..7478463 100644 --- a/hbvm/fuzz/fuzz_targets/vm.rs +++ b/hbvm/fuzz/fuzz_targets/vm.rs @@ -39,6 +39,8 @@ fuzz_target!(|data: &[u8]| { for (i, page) in pages.into_iter().enumerate() { unmap_and_dealloc(&mut vm.memory, page, i as u64 * 4096); } + + let _ = unsafe { Box::from_raw(vm.memory.root_pt) }; } }); diff --git a/hbvm/src/main.rs b/hbvm/src/main.rs index 7bb4502..04d654d 100644 --- a/hbvm/src/main.rs +++ b/hbvm/src/main.rs @@ -47,12 +47,12 @@ fn main() -> Result<(), Box> { println!("Program interrupt: {:?}", vm.run()); println!("{:?}", vm.registers); - println!("{:?}", core::slice::from_raw_parts(data, 4096)); std::alloc::dealloc( data, std::alloc::Layout::from_size_align_unchecked(4096, 4096), ); vm.memory.unmap(8192).unwrap(); + let _ = Box::from_raw(vm.memory.root_pt); } } Ok(())