Kernel: Fixed use-after-free

This commit is contained in:
pca006132 2020-07-07 15:51:12 +08:00
parent 0f797284e2
commit f1750cf8cd
1 changed files with 3 additions and 0 deletions

View File

@ -325,6 +325,7 @@ pub fn main_core1() {
let mut current_modinit: Option<u32> = None; let mut current_modinit: Option<u32> = None;
let mut current_typeinfo: Option<u32> = None; let mut current_typeinfo: Option<u32> = None;
let mut library_handle: Option<dyld::Library> = None;
loop { loop {
let message = core1_rx.recv(); let message = core1_rx.recv();
match *message { match *message {
@ -351,6 +352,7 @@ pub fn main_core1() {
dcci_slice(library.image.data); dcci_slice(library.image.data);
core1_tx.send(Message::LoadCompleted); core1_tx.send(Message::LoadCompleted);
library_handle = Some(library);
}, },
Err(error) => { Err(error) => {
error!("failed to load shared library: {}", error); error!("failed to load shared library: {}", error);
@ -372,6 +374,7 @@ pub fn main_core1() {
KERNEL_CHANNEL_1TO0 = ptr::null_mut(); KERNEL_CHANNEL_1TO0 = ptr::null_mut();
} }
} }
library_handle = None;
info!("kernel finished"); info!("kernel finished");
core1_tx.send(Message::KernelFinished); core1_tx.send(Message::KernelFinished);
} }