pitrou commented on a change in pull request #7733:
URL: https://github.com/apache/arrow/pull/7733#discussion_r453835979
##########
File path: cpp/src/arrow/array/data.cc
##########
@@ -105,6 +106,22 @@ std::shared_ptr<ArrayData> ArrayData::Slice(int64_t off,
int64_t len) const {
return copy;
}
+Result<std::shared_ptr<ArrayData>> ArrayData::SliceSafe(int64_t off, int64_t
len) const {
+ if (off < 0) {
+ return Status::Invalid("Negative array slice offset");
+ }
+ if (len < 0) {
+ return Status::Invalid("Negative array slice length");
+ }
+ if (internal::HasAdditionOverflow(off, len)) {
+ return Status::Invalid("Array slice would overflow");
+ }
+ if (off + len > length) {
+ return Status::Invalid("Array slice would exceed array length");
+ }
Review comment:
Added a comment, thank you :-)
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]