From d27ac65df3a4127c0470da9762d1a6d4729055cd Mon Sep 17 00:00:00 2001 From: WangRunji Date: Fri, 16 Nov 2018 01:33:25 +0800 Subject: [PATCH] fix load program slice error --- kernel/src/process/context.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/src/process/context.rs b/kernel/src/process/context.rs index 57df119..e6810b5 100644 --- a/kernel/src/process/context.rs +++ b/kernel/src/process/context.rs @@ -83,7 +83,9 @@ impl ContextImpl { let mem_size = ph.mem_size() as usize; let target = unsafe { ::core::slice::from_raw_parts_mut(virt_addr as *mut u8, mem_size) }; - target[..file_size].copy_from_slice(&data[offset..offset + file_size]); + if file_size != 0 { + target[..file_size].copy_from_slice(&data[offset..offset + file_size]); + } target[file_size..].iter_mut().for_each(|x| *x = 0); } ustack_top = push_args_at_stack(args, ustack_top);