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


##########
cpp/src/gandiva/gdv_function_stubs_test.cc:
##########
@@ -1127,6 +1190,15 @@ TEST(TestGdvFnStubs, TestTranslate) {
   result = translate_utf8_utf8_utf8(ctx_ptr, "987654321", 9, "123456789", 9, 
"0123456789",
                                     10, &out_len);
   EXPECT_EQ(expected, std::string(result, out_len));
+
+  int32_t bad_in_len = std::numeric_limits<int32_t>::max() / 4 + 1;
+  out_len = -1;
+  result =
+      translate_utf8_utf8_utf8(ctx_ptr, "ABCDE", bad_in_len, "B", 1, "C", 1, 
&out_len);

Review Comment:
   This overflow test passes a 5-byte string literal with a huge `in_len`. 
`translate_utf8_utf8_utf8` scans `in_len` bytes while looking for multibyte 
characters before reaching the overflow check, so this test can read far past 
the literal (and fail under sanitizers or crash) before it ever asserts the 
expected error. Make the test trigger the multibyte branch immediately (for 
example with a high-bit first byte) or use a buffer whose size matches the 
supplied length.
   



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