js8544 commented on code in PR #38504:
URL: https://github.com/apache/arrow/pull/38504#discussion_r1389019657
##########
cpp/src/arrow/array/util.cc:
##########
@@ -669,11 +671,29 @@ class RepeatedArrayFactory {
enable_if_base_binary<T, Status> Visit(const T&) {
const std::shared_ptr<Buffer>& value = scalar<T>().value;
std::shared_ptr<Buffer> values_buffer, offsets_buffer;
- RETURN_NOT_OK(CreateBufferOf(value->data(), value->size(),
&values_buffer));
auto size = static_cast<typename T::offset_type>(value->size());
+
+ typename T::offset_type length_casted;
+ if (length_ < 0) {
+ return Status::Invalid("length cannot be negative: " +
std::to_string(length_));
+ } else 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()));
Review Comment:
On second thought, what if the input scalar an empty string ""? Can the
length be larger than int32::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]