From a116142f6346193f272528e68c09af5eda771c0d Mon Sep 17 00:00:00 2001 From: pca006132 Date: Thu, 3 Sep 2020 12:56:10 +0800 Subject: [PATCH] libsupport_zynq/ram: check ptr range for deallocation --- libsupport_zynq/src/ram.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libsupport_zynq/src/ram.rs b/libsupport_zynq/src/ram.rs index 4ee72be..de5e408 100644 --- a/libsupport_zynq/src/ram.rs +++ b/libsupport_zynq/src/ram.rs @@ -34,7 +34,10 @@ unsafe impl GlobalAlloc for CortexA9Alloc { } unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { - if cfg!(not(feature = "alloc_core")) || MPIDR.read().cpu_id() == 0 { + if cfg!(not(feature = "alloc_core")) + || ((&__heap0_start as *const usize as usize <= ptr as usize) + && ((ptr as usize) < &__heap0_end as *const usize as usize)) + { &self.0 } else { &self.1