From f1750cf8cd194c28905f9ea55f8a172264ae0dc0 Mon Sep 17 00:00:00 2001 From: pca006132 Date: Tue, 7 Jul 2020 15:51:12 +0800 Subject: [PATCH] Kernel: Fixed use-after-free --- src/runtime/src/kernel.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/runtime/src/kernel.rs b/src/runtime/src/kernel.rs index 8539b210..e5101f17 100644 --- a/src/runtime/src/kernel.rs +++ b/src/runtime/src/kernel.rs @@ -325,6 +325,7 @@ pub fn main_core1() { let mut current_modinit: Option = None; let mut current_typeinfo: Option = None; + let mut library_handle: Option = None; loop { let message = core1_rx.recv(); match *message { @@ -351,6 +352,7 @@ pub fn main_core1() { dcci_slice(library.image.data); core1_tx.send(Message::LoadCompleted); + library_handle = Some(library); }, Err(error) => { error!("failed to load shared library: {}", error); @@ -372,6 +374,7 @@ pub fn main_core1() { KERNEL_CHANNEL_1TO0 = ptr::null_mut(); } } + library_handle = None; info!("kernel finished"); core1_tx.send(Message::KernelFinished); }