Skip to content

Commit

Permalink
Fix NULL dereference in Condvar::notify_all
Browse files Browse the repository at this point in the history
  • Loading branch information
Amanieu committed May 7, 2017
1 parent a27b24e commit 8576e09
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/condvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,19 @@ impl Condvar {
#[inline]
pub fn notify_all(&self) {
// Nothing to do if there are no waiting threads
if self.state.load(Ordering::Relaxed).is_null() {
let state = self.state.load(Ordering::Relaxed);
if state.is_null() {
return;
}

self.notify_all_slow();
self.notify_all_slow(state);
}

#[cold]
#[inline(never)]
fn notify_all_slow(&self) {
fn notify_all_slow(&self, mutex: *mut RawMutex) {
unsafe {
// Unpark one thread and requeue the rest onto the mutex
let mutex = self.state.load(Ordering::Relaxed);
let from = self as *const _ as usize;
let to = mutex as usize;
let validate = || {
Expand Down

0 comments on commit 8576e09

Please sign in to comment.