Arawoof06 commented on code in PR #50381:
URL: https://github.com/apache/arrow/pull/50381#discussion_r3533806432
##########
cpp/src/gandiva/precompiled/string_ops.cc:
##########
@@ -2480,13 +2495,6 @@ const char* byte_substr_binary_int32_int32(gdv_int64
context, const char* text,
return "";
}
- int32_t startPos = 0;
- if (offset >= 0) {
- startPos = offset - 1;
- } else if (text_len + offset >= 0) {
- startPos = text_len + offset;
- }
-
// calculate end position from length and truncate to upper value bounds
if (startPos + length > text_len) {
Review Comment:
Good catch. Switched the truncation to compare against the remaining bytes
(length > text_len - startPos) so it stays in int32 with no overflow, since
startPos < text_len is guaranteed by the guard above. Added a case with length
= INT32_MAX at offset 2 which now truncates to the remaining 9 bytes instead of
running off the end.
--
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]