bkietz commented on code in PR #38504:
URL: https://github.com/apache/arrow/pull/38504#discussion_r1394400239
##########
cpp/src/arrow/array/util.cc:
##########
@@ -844,6 +848,18 @@ class RepeatedArrayFactory {
template <typename OffsetType>
Status CreateOffsetsBuffer(OffsetType value_length, std::shared_ptr<Buffer>*
out) {
+ OffsetType total_size;
+ if (MultiplyWithOverflow(value_length, static_cast<OffsetType>(length_),
+ &total_size)) {
+ return Status::Invalid("offset overflow in repeated array construction");
+ }
+
+ if (length_ > std::numeric_limits<OffsetType>::max()) {
+ return Status::Invalid(
+ "length exceeds the maximum value of offset_type: ",
std::to_string(length_),
+ " is greater than ",
std::to_string(std::numeric_limits<OffsetType>::max()));
Review Comment:
```suggestion
int64_t total_size;
if (MultiplyWithOverflow(static_cast<int64_t>(value_length), length_,
&total_size) ||
total_size > std::numeric_limits<OffsetType>::max()) {
return Status::Invalid(
"length exceeds the maximum value of offset_type: ",
std::to_string(total_size),
" is greater than ",
std::to_string(std::numeric_limits<OffsetType>::max()));
```
--
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]