Browse Source

handle the null case

Paul Sajna 7 years ago
parent
commit
52acce0d34
1 changed files with 5 additions and 3 deletions
  1. 5 3
      src/platform/src/redox/mod.rs

+ 5 - 3
src/platform/src/redox/mod.rs

@@ -204,9 +204,11 @@ pub fn unlink(path: *const c_char) -> c_int {
 
 
 pub fn waitpid(pid: pid_t, stat_loc: *mut c_int, options: c_int) -> pid_t {
 pub fn waitpid(pid: pid_t, stat_loc: *mut c_int, options: c_int) -> pid_t {
     unsafe {
     unsafe {
-        let mut temp: usize = *stat_loc as usize;
-        let res = e(syscall::waitpid(pid as usize, &mut temp, options as usize));
-        *stat_loc = temp as c_int;
+        let mut temp: usize = 0;
+        let mut res = e(syscall::waitpid(pid as usize, &mut temp, options as usize));
+        if !stat_loc.is_null()  {
+            *stat_loc = temp as c_int;
+        }
         res
         res
     }
     }
 }
 }