Skip to content

Commit 25e4fdb

Browse files
authored
GH-48094: [C++] Restrict SecureString capacity tail check to Linux (#49906)
### Rationale for this change - The test reads the unused tail of string past size(), which is undefined. libstdc++ keeps that range addressable, but MSVC does not. - Ensure the check is not run for MSVC. Existing assertions still run, the unused capacity is not asserted on non linux platforms. - Closes #48094. ### What changes are included in this PR? - Guard for platform specific behavior. ### Are these changes tested? - Yes ### Are there any user-facing changes? - Yes * GitHub Issue: #48094 Authored-by: Arnav Balyan <arnavbalyan1@gmail.com> Signed-off-by: Antoine Pitrou <antoine@python.org>
1 parent 1fc0e19 commit 25e4fdb

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

cpp/src/arrow/util/secure_string_test.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,14 @@ namespace arrow::util::test {
3030
# define CAN_TEST_DEALLOCATED_AREAS 1
3131
#endif
3232

33+
// Reading the unused tail past size() is undefined behavior, exclude MSVC
34+
// from the tail check.
3335
std::string_view StringArea(const std::string& string) {
36+
#if defined(_MSC_VER)
37+
return {string.data(), string.size()};
38+
#else
3439
return {string.data(), string.capacity()};
40+
#endif
3541
}
3642

3743
// same as GTest ASSERT_PRED_FORMAT2 macro, but without the outer GTEST_ASSERT_

0 commit comments

Comments
 (0)