From 4353ef33cd64607558e3f501fd5a4d57a3f3e222 Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Sat, 15 Apr 2023 13:34:57 +0200 Subject: [PATCH] Fix pthread_join by not writing if retval == NULL. --- src/header/pthread/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/header/pthread/mod.rs b/src/header/pthread/mod.rs index f71244a6..81e026ef 100644 --- a/src/header/pthread/mod.rs +++ b/src/header/pthread/mod.rs @@ -145,7 +145,9 @@ pub use tls::*; pub unsafe extern "C" fn pthread_join(thread: pthread_t, retval: *mut *mut c_void) -> c_int { match pthread::join(&*thread.cast()) { Ok(pthread::Retval(ret)) => { - core::ptr::write(retval, ret); + if !retval.is_null() { + core::ptr::write(retval, ret); + } 0 } Err(pthread::Errno(error)) => error, -- GitLab