Skip to content

Commit 17a7c6a

Browse files
committed
fix pointer aliasing in ItemSliceSend
Same reasoning as for the fix in in_parallel.rs. Thanks to @cramertj for spotting this.
1 parent c684b26 commit 17a7c6a

File tree

1 file changed

+3
-3
lines changed
  • gix-pack/src/cache/delta/traverse

1 file changed

+3
-3
lines changed

gix-pack/src/cache/delta/traverse/util.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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
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> {
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
})

0 commit comments

Comments
 (0)