Copilot commented on code in PR #49813:
URL: https://github.com/apache/arrow/pull/49813#discussion_r3238589365


##########
cpp/src/gandiva/gdv_string_function_stubs.cc:
##########
@@ -579,15 +623,24 @@ const char* translate_utf8_utf8_utf8(int64_t context, 
const char* in, int32_t in
     return in;
   }
 
+  int32_t alloc_length = 0;
+  // Check overflow: 4 * in_len
+  if (ARROW_PREDICT_FALSE(
+          arrow::internal::MultiplyWithOverflow(4, in_len, &alloc_length))) {

Review Comment:
   This overflow check is applied before determining whether the translation 
actually needs the multibyte path that allocates `4 * in_len`. For large 
ASCII-only inputs, the function now returns an overflow error even though the 
ASCII path only allocates `in_len` bytes and would not overflow. Move the `4 * 
in_len` check into the multibyte branch (after `has_multi_byte` is known), or 
otherwise only apply it when the expanded allocation is needed.



-- 
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]

Reply via email to