bkietz commented on code in PR #38504:
URL: https://github.com/apache/arrow/pull/38504#discussion_r1394362901
##########
cpp/src/arrow/array/util.cc:
##########
@@ -862,6 +854,12 @@ class RepeatedArrayFactory {
template <typename OffsetType>
Status CreateOffsetsBuffer(OffsetType value_length, std::shared_ptr<Buffer>*
out) {
+ if (length_ > std::numeric_limits<OffsetType>::max()) {
Review Comment:
... because what you need to check here is not `length_` but `value_length`,
however `value_length` is already cast to OffsetType here
##########
cpp/src/arrow/array/util.cc:
##########
@@ -673,22 +673,14 @@ class RepeatedArrayFactory {
std::shared_ptr<Buffer> values_buffer, offsets_buffer;
auto size = static_cast<typename T::offset_type>(value->size());
- typename T::offset_type length_casted;
- if (length_ > std::numeric_limits<typename T::offset_type>::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<typename T::offset_type>::max()));
- }
- length_casted = static_cast<typename T::offset_type>(length_);
-
typename T::offset_type total_size;
- if (MultiplyWithOverflow(size, length_casted, &total_size)) {
+ if (MultiplyWithOverflow(size, static_cast<typename
T::offset_type>(length_),
Review Comment:
I think in order to make this correct, this multiplication must be moved
into CreateOffsetsBuffer.
--
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]