neilconway commented on code in PR #11770:
URL: https://github.com/apache/arrow-rs/pull/11770#discussion_r4373083500


##########
arrow-array/src/builder/generic_bytes_view_builder.rs:
##########
@@ -224,25 +224,39 @@ impl<T: ByteViewType + ?Sized> GenericByteViewBuilder<T> {
     /// Appends an array to the builder.
     /// This will flush any in-progress block and append the data buffers
     /// and add the (adapted) views.
+    ///
+    /// # Panics
+    ///
+    /// Panics if the builder would hold more than `u32::MAX` data buffers
     pub fn append_array(&mut self, array: &GenericByteViewArray<T>) {
         self.flush_in_progress();
         // keep original views if this array is the first to be added or if 
there are no data buffers (all inline views)
         let keep_views = self.completed.is_empty() || 
array.data_buffers().is_empty();
         let starting_buffer = self.completed.len() as u32;
 
         self.completed.extend(array.data_buffers().iter().cloned());
+        assert!(
+            u32::try_from(self.completed.len()).is_ok(),
+            "Too many blocks"
+        );

Review Comment:
   On an overflow, the behavior before this PR was to panic in debug mode. In 
release mode, the buffer index would wrap and point at the wrong buffer.



-- 
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