alamb commented on code in PR #9872:
URL: https://github.com/apache/arrow-rs/pull/9872#discussion_r3175276531


##########
arrow-array/src/array/fixed_size_binary_array.rs:
##########
@@ -120,6 +122,8 @@ impl FixedSizeBinaryArray {
             }
         };
 
+        Self::validate_lengths(s, len)?;

Review Comment:
   this is the key check -- it prevents creating arrays that are susceptible to 
this overflow
   
   I added it on each constructor path



##########
arrow-array/src/array/fixed_size_binary_array.rs:
##########
@@ -310,8 +346,16 @@ impl FixedSizeBinaryArray {
                     // Now that we know how large each element is we can 
reserve
                     // sufficient capacity in the underlying mutable buffer for
                     // the data.
-                    buffer.reserve(iter_size_hint * len);
-                    buffer.extend_zeros(slice.len() * prepend);
+                    if let Some(capacity) = iter_size_hint.checked_mul(len) {

Review Comment:
   I also updated some of the other arithmetic to used checked multiplication



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