diff --git a/src/header/pthread/rwlock.rs b/src/header/pthread/rwlock.rs index e4682f067c..af943966ec 100644 --- a/src/header/pthread/rwlock.rs +++ b/src/header/pthread/rwlock.rs @@ -1,6 +1,6 @@ use super::*; -use crate::header::errno::EBUSY; +use crate::header::errno::{EBUSY, EINVAL}; use crate::pthread::Pshared; @@ -97,9 +97,11 @@ pub unsafe extern "C" fn pthread_rwlockattr_setpshared( attr: *mut pthread_rwlockattr_t, pshared: c_int, ) -> c_int { - (unsafe { *attr.cast::() }).pshared = - Pshared::from_raw(pshared).expect("invalid pshared in pthread_rwlockattr_setpshared"); + let Some(pshared) = Pshared::from_raw(pshared) else { + return EINVAL; + }; + (unsafe { *attr.cast::() }).pshared = pshared; 0 }