Skip to content

Commit

Permalink
Fix casting bug
Browse files Browse the repository at this point in the history
  • Loading branch information
terrarier2111 committed Jun 5, 2023
1 parent 93f05a2 commit 6cf274c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ impl<T, M: Metadata, const AUTO_FREE_IDS: bool> Entry<T, M, AUTO_FREE_IDS> {
self.guard.store(GUARD_EMPTY, Ordering::Release);
// check if we are a "main" entry and our thread is finished
let outstanding = self.outstanding_refs.load(Ordering::Acquire);
if let Some(outstanding) = unsafe { outstanding.as_ref() } {
if let Some(outstanding) = unsafe { outstanding.as_ref() } { // FIXME: this as_ref call leads to a use-after-free
if outstanding.fetch_sub(1, Ordering::AcqRel) != 1 {
// there are outstanding references left, so we can't free the id yet.
return;
Expand Down
2 changes: 1 addition & 1 deletion src/thread_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl FreeList {
let mut outstanding = 0;
for entry in free_list.unwrap().iter() {
// sum up all the "failed" cleanups
if unsafe { !entry.1.cleanup(*entry.0 as *const Entry<()>, &outstanding_shared as *const Box<AtomicUsize> as *const AtomicUsize) } {
if unsafe { !entry.1.cleanup(*entry.0 as *const Entry<()>, outstanding_shared.deref() as *const AtomicUsize) } {
outstanding += 1;
}
}
Expand Down

0 comments on commit 6cf274c

Please sign in to comment.