tustvold commented on code in PR #6616:
URL: https://github.com/apache/arrow-rs/pull/6616#discussion_r1812213784


##########
arrow-select/src/take.rs:
##########
@@ -2382,4 +2389,29 @@ mod tests {
         let array = take(&array, &indicies, None).unwrap();
         assert_eq!(array.len(), 3);
     }
+
+    #[test]
+    fn test_take_bytes_null_indices_modified() {
+        let indices = Int32Array::new(
+            vec![0, 0, 0, 0].into(),
+            Some(NullBuffer::from_iter(vec![false, true, true, true])),
+        );
+        let values = StringArray::from(vec![Some("foo")]);
+        let r = take(&values, &indices, None).unwrap();
+
+        // Modify indices null buffer
+        let (_, _, nulls) = indices.into_parts();
+        assert!(nulls.is_some());
+        let null_buffer = nulls.unwrap();
+        let binding = null_buffer.into_inner().into_inner();
+        let null_slice = binding.data_ptr();
+        for i in 0..4 {
+            unsafe {
+                bit_util::unset_bit_raw(null_slice.as_ptr(), i);

Review Comment:
   I believe this is UB, you're mutating a pointer you don't have exclusive 
access to



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to