Skip to content

Commit d138ae0

Browse files
committed
fix: use checked conversion for AVX2 table limit
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
1 parent 844918e commit d138ae0

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

  • vortex-array/src/arrays/fixed_width/take/small_table

‎vortex-array/src/arrays/fixed_width/take/small_table/avx2.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use arch::_mm256_testz_si256;
2525
use vortex_buffer::Buffer;
2626
use vortex_buffer::BufferAllocatorRef;
2727
use vortex_buffer::BufferMut;
28+
use vortex_error::VortexExpect;
2829

2930
use super::super::FixedWidthTakeValue;
3031
use super::super::HAS_AVX2;
@@ -99,7 +100,9 @@ unsafe fn take_avx2<T: FixedWidthTakeValue>(
99100
// SAFETY: the table contains 16 initialized one-byte values.
100101
let table = unsafe { _mm_loadu_si128(table.as_ptr().cast()) };
101102
let table = _mm256_broadcastsi128_si256(table);
102-
let limit = _mm256_set1_epi8((values.len() - 1) as i8);
103+
let limit = _mm256_set1_epi8(
104+
i8::try_from(values.len() - 1).vortex_expect("table contains at most 16 values"),
105+
);
103106
let mut invalid = _mm256_setzero_si256();
104107
let mut output = BufferMut::<T>::with_capacity_in(indices.len(), allocator.clone());
105108
let spare = output.spare_capacity_mut();

0 commit comments

Comments
 (0)