This is an automated email from the ASF dual-hosted git repository.

pitrou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 25e4fdb1ba GH-48094: [C++] Restrict SecureString capacity tail check 
to Linux (#49906)
25e4fdb1ba is described below

commit 25e4fdb1ba79cc72fbb00c046a888cdf595ee9be
Author: Arnav Balyan <[email protected]>
AuthorDate: Tue May 5 18:59:09 2026 +0530

    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 <[email protected]>
    Signed-off-by: Antoine Pitrou <[email protected]>
---
 cpp/src/arrow/util/secure_string_test.cc | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/cpp/src/arrow/util/secure_string_test.cc 
b/cpp/src/arrow/util/secure_string_test.cc
index f2dfda5ca6..ade334e002 100644
--- a/cpp/src/arrow/util/secure_string_test.cc
+++ b/cpp/src/arrow/util/secure_string_test.cc
@@ -30,8 +30,14 @@ namespace arrow::util::test {
 #  define CAN_TEST_DEALLOCATED_AREAS 1
 #endif
 
+// Reading the unused tail past size() is undefined behavior, exclude MSVC
+// from the tail check.
 std::string_view StringArea(const std::string& string) {
+#if defined(_MSC_VER)
+  return {string.data(), string.size()};
+#else
   return {string.data(), string.capacity()};
+#endif
 }
 
 // same as GTest ASSERT_PRED_FORMAT2 macro, but without the outer GTEST_ASSERT_

Reply via email to