Dricmoy opened a new pull request, #52451: URL: https://github.com/apache/arrow/pull/52451
### Rationale for this change `binary_slice` uses `INT64_MAX` as its default stop. The output-size estimate used that value directly, which could overflow for multiple input values and cause valid calls such as `binary_slice(values, 1)` to fail with `ArrowInvalid: Negative buffer resize`. Closes #51222. ### What changes are included in this PR? Clamp the stop value to the available input byte range before calculating the maximum output size, matching the existing `utf8_slice_codeunits` implementation. Add regression coverage for both binary and large-binary arrays. ### Are these changes tested? Yes. - Focused `*SliceBytes*` C++ tests: 10 passed. - Full `arrow-compute-scalar-type-test`: 348 passed, with one pre-existing disabled test. - C++ formatting and cpplint checks passed. - `git diff --check` passed. ### Are there any user-facing changes? Yes. Calling `binary_slice` with its default stop on sufficiently long input now returns the expected slice instead of raising `ArrowInvalid: Negative buffer resize`. ### Was AI used for this PR? In accordance to the [AI generation guidelines](https://arrow.apache.org/docs/developers/overview.html#ai-generated-code), please disclose below whether and how AI was used in this PR. OpenAI Codex assisted with investigation, implementation, test selection, validation, and drafting this description. I reviewed the change, understand it, and take responsibility for the contribution. **PR code and description written by:** - [ ] Human - [x] AI **Reviewed before submission by:** - [x] Human - [x] AI - [ ] Not reviewed -- 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]
