neilconway commented on code in PR #11656:
URL: https://github.com/apache/arrow-rs/pull/11656#discussion_r4303979480
##########
arrow-buffer/src/buffer/mutable.rs:
##########
@@ -995,11 +995,20 @@ impl MutableBuffer {
mut iterator: I,
) {
let item_size = std::mem::size_of::<T>();
- let (lower, _) = iterator.size_hint();
- let additional = lower * item_size;
- self.reserve(additional);
+ let (lower, upper) = iterator.size_hint();
+ if let Some(byte_count) = lower.checked_mul(item_size) {
+ self.reserve(byte_count);
+ if upper == Some(lower) {
Review Comment:
Yep, I covered similar ground while implementing this; sorry, should
probably have mentioned that in the writeup. Documenting it and describing it
in the PR description makes sense, will do.
--
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]