Skip to content

Commit 2cc8053

Browse files
authored
fix: bvector subscription may modify padding bits (#401)
* fix: bvector subscription may modify padding bits Signed-off-by: Mingzhuo Yin <yinmingzhuo@gmail.com> * cargo clippy Signed-off-by: Mingzhuo Yin <yinmingzhuo@gmail.com> --------- Signed-off-by: Mingzhuo Yin <yinmingzhuo@gmail.com>
1 parent 95b7dc6 commit 2cc8053

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/datatype/subscript_bvecf32.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ fn _vectors_bvecf32_subscript(_fcinfo: pgrx::pg_sys::FunctionCallInfo) -> Datum
168168
if start % BVEC_WIDTH as u16 == 0 {
169169
let start_idx = start as usize / BVEC_WIDTH;
170170
let end_idx = (end as usize).div_ceil(BVEC_WIDTH);
171-
values
172-
.data_mut()
173-
.copy_from_slice(&input.for_borrow().data()[start_idx..end_idx]);
171+
let slice = values.data_mut();
172+
slice.copy_from_slice(&input.for_borrow().data()[start_idx..end_idx]);
173+
slice[end_idx - start_idx - 1] &= (1 << (end as usize % BVEC_WIDTH)) - 1;
174174
} else {
175175
let mut i = 0;
176176
let mut j = start as usize;

0 commit comments

Comments
 (0)