From c59192389f8a196f02600cea6cf2f3ed50130b83 Mon Sep 17 00:00:00 2001 From: Yilin Chen Date: Fri, 16 Dec 2022 00:53:41 +0800 Subject: [PATCH] Fix get_unchecked UB by raw pointer calculation Signed-off-by: Yilin Chen --- crossbeam-skiplist/src/base.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crossbeam-skiplist/src/base.rs b/crossbeam-skiplist/src/base.rs index d27c531b5..7d9bf5119 100644 --- a/crossbeam-skiplist/src/base.rs +++ b/crossbeam-skiplist/src/base.rs @@ -36,7 +36,7 @@ impl Index for Tower { fn index(&self, index: usize) -> &Atomic> { // This implementation is actually unsafe since we don't check if the // index is in-bounds. But this is fine since this is only used internally. - unsafe { self.pointers.get_unchecked(index) } + unsafe { &*(&self.pointers as *const Atomic>).add(index) } } }