History

fix pointer aliasing in ItemSliceSend

Same reasoning as for the fix in in_parallel.rs. Thanks to @cramertj for spotting this.

Martin von Zweigbergk committed 2 years ago

Commit 17a7c6a1 parent c684b261 file · +3 −3Browse files

Unified · Split

gix-pack/src/cache/delta/traverse/util.rs+3−3
@@ -1,6 +1,6 @@
11 use crate::cache::delta::Item;
22
3−pub struct ItemSliceSend<T>(*mut [T])
3+pub struct ItemSliceSend<T>(*mut T)
44 where
55 T: Send;
66
@@ -9,7 +9,7 @@ where · 2 unmodified lines
99 T: Send,
1010 {
1111 pub fn new(items: &mut [T]) -> Self {
12− ItemSliceSend(std::ptr::slice_from_raw_parts_mut(items.as_mut_ptr(), items.len()))
12+ ItemSliceSend(items.as_mut_ptr())
1313 }
1414 }
1515
@@ -66,7 +66,7 @@ impl<'a, T: Send> Node<'a, T> { · 50 unmodified lines
6666 // SAFETY: The resulting mutable pointer cannot be yielded by any other node.
6767 #[allow(unsafe_code)]
6868 Node {
69− item: &mut unsafe { &mut *children.0 }[index as usize],
69+ item: unsafe { &mut *children.0.add(index as usize) },
7070 child_items: children.clone(),
7171 }
7272 })