Skip to content

Commit

Permalink
Ensure that conc::Treiber::drop doesnt cause double-drop of the inner.
Browse files Browse the repository at this point in the history
  • Loading branch information
ticki committed Jun 29, 2017
1 parent 6bd5bd5 commit 0b15e8b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions conc/src/sync/treiber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ impl<T> Drop for Treiber<T> {
// structure. They're all gone, thus we can safely mess with the inner structure.

unsafe {
let ptr = *self.head.get_inner_mut().get_mut();
let ptr = self.head.get_inner_mut().get_mut();

if !ptr.is_null() {
// Call destructors on the stack.
(*ptr).destroy();
(**ptr).destroy();
// Finally deallocate the pointer itself.
drop(Box::from_raw(ptr));
drop(Box::from_raw(*ptr));
// Set it to null to prevent `Atomic`'s destructor from running.
*ptr = ptr::null_mut();
}
}
}
Expand Down

0 comments on commit 0b15e8b

Please sign in to comment.