-
Notifications
You must be signed in to change notification settings - Fork 79
Description
Reviewing this crate's use of unsafe identified a few issues:
string-cache/src/dynamic_set.rs
Line 63 in 34f914c
| return NonNull::from(&mut **entry); |
string-cache/src/dynamic_set.rs
Line 98 in 34f914c
| let entry_ptr: *mut Entry = &mut **entry_ptr; |
These construct a &mut Entry that may exist concurrently with the &Entry references unsafely constructed by many methods on Atom. These should use the new ptr::addr_of_mut helper which avoids the hazard.
string-cache/src/dynamic_set.rs
Line 105 in 34f914c
| current = unsafe { &mut (*entry_ptr).next_in_bucket }; |
This similarly constructs a unique reference to a field, which may actually get written while an aliasing &Entry is live elsewhere. This probably needs an UnsafeCell.
Line 309 in 34f914c
| let buffer = unsafe { &mut *buffer.as_mut_ptr() }; |
This constructs a reference to uninitialized memory. Raw pointer writes should be used instead.