Copilot commented on code in PR #50381:
URL: https://github.com/apache/arrow/pull/50381#discussion_r3526704896
##########
cpp/src/gandiva/precompiled/string_ops.cc:
##########
@@ -2487,6 +2487,13 @@ const char* byte_substr_binary_int32_int32(gdv_int64
context, const char* text,
startPos = text_len + offset;
}
+ // an offset past the end of the text leaves nothing to copy; without this
the
+ // truncation below yields a negative *out_len that memcpy reads as a huge
size
+ if (startPos >= text_len) {
+ *out_len = 0;
+ return "";
Review Comment:
The new `startPos >= text_len` early-return happens after allocating `ret`.
That means offsets past the end still allocate `text_len` bytes per call, and
can incorrectly set an OOM error even though the correct result is an empty
string that needs no allocation. Compute `startPos` and do this bounds check
before calling `gdv_fn_context_arena_malloc`.
--
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]