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


##########
arrow-buffer/src/buffer/mutable.rs:
##########
@@ -583,7 +586,11 @@ impl MutableBuffer {
     /// Extends the buffer by `additional` bytes equal to `0u8`, incrementing 
its capacity if needed.
     #[inline]
     pub fn extend_zeros(&mut self, additional: usize) {
-        self.resize(self.len + additional, 0);
+        let new_len = self
+            .len
+            .checked_add(additional)
+            .expect("buffer length overflow");

Review Comment:
   > I do agree it should be a very rare error, but I've also been unpleasantly 
surprised at how often 32-bit StringArray offsets blow up in practice.
   
   Yeah, i32 (2GB strings) is shockingly common



##########
arrow-buffer/src/buffer/mutable.rs:
##########
@@ -583,7 +586,11 @@ impl MutableBuffer {
     /// Extends the buffer by `additional` bytes equal to `0u8`, incrementing 
its capacity if needed.
     #[inline]
     pub fn extend_zeros(&mut self, additional: usize) {
-        self.resize(self.len + additional, 0);
+        let new_len = self
+            .len
+            .checked_add(additional)
+            .expect("buffer length overflow");

Review Comment:
   > I don't know if there's a way to provide a fallible version of this API, 
for paranoid consumers to use?
   
   I mean we could add a `try_extend_zeros` or something 🤔 



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