kou commented on code in PR #50441:
URL: https://github.com/apache/arrow/pull/50441#discussion_r3591985248
##########
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:
Oh, sorry. `snprintf(size)` truncates the error message without `%.*s`.
--
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]