Arawoof06 commented on code in PR #50441:
URL: https://github.com/apache/arrow/pull/50441#discussion_r3592992264


##########
cpp/src/gandiva/precompiled/time_test.cc:
##########
@@ -67,17 +65,15 @@ TEST(TestTime, TestCastDateInvalidUnterminated) {
   ExecutionContext context;
   int64_t context_ptr = reinterpret_cast<int64_t>(&context);
 
-  // The invalid-value error message is built from the raw input pointer. Hold
-  // the input in an exactly-sized heap buffer with no trailing NUL so that
-  // formatting the error must respect `length` instead of scanning for a NUL;
-  // any over-read past the buffer trips AddressSanitizer.
-  const char bytes[] = {'1', '9', '7', '2', '2', '2', '2', '2', '2', '2'};
-  const auto length = static_cast<int32_t>(sizeof(bytes));
-  std::unique_ptr<char[]> input(new char[length]);
-  std::memcpy(input.get(), bytes, length);
-
-  EXPECT_EQ(castDATE_utf8(context_ptr, input.get(), length), 0);
-  EXPECT_EQ(context.get_error(), "Not a valid date value 1972222222");
+  // The invalid-value error message is built from the raw input pointer. Pass 
a
+  // length that stops one byte short of the trailing sentinel so the formatter
+  // must respect `length` rather than scanning for a NUL; without the fix the
+  // sentinel leaks into the error message.
+  const std::string input = "197201234X";

Review Comment:
   Good catch, you're right on both counts. Restored the exactly-sized 
non-NUL-terminated heap buffers for all three tests so the over-read actually 
reaches ASAN and the test fails without the fix. Kept 197201234 as the date 
value per the distinct-digits suggestion.



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