| 23 | namespace internal { |
| 24 | |
| 25 | static inline Status CheckSliceParams(int64_t object_length, int64_t slice_offset, |
| 26 | int64_t slice_length, const char* object_name) { |
| 27 | if (ARROW_PREDICT_FALSE(slice_offset < 0)) { |
| 28 | return Status::IndexError("Negative ", object_name, " slice offset"); |
| 29 | } |
| 30 | if (ARROW_PREDICT_FALSE(slice_length < 0)) { |
| 31 | return Status::IndexError("Negative ", object_name, " slice length"); |
| 32 | } |
| 33 | int64_t offset_plus_length; |
| 34 | if (ARROW_PREDICT_FALSE( |
| 35 | internal::AddWithOverflow(slice_offset, slice_length, &offset_plus_length))) { |
| 36 | return Status::IndexError(object_name, " slice would overflow"); |
| 37 | } |
| 38 | if (ARROW_PREDICT_FALSE(offset_plus_length > object_length)) { |
| 39 | return Status::IndexError(object_name, " slice would exceed ", object_name, |
| 40 | " length"); |
| 41 | } |
| 42 | return Status::OK(); |
| 43 | } |
| 44 | |
| 45 | } // namespace internal |
| 46 | } // namespace arrow |
no test coverage detected