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

apitrou 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 8133a20c70 GH-40652: [C++] Enlarge dest buffer according to dest 
offset for `CopyBitmap` benchmark (#40769)
8133a20c70 is described below

commit 8133a20c70cd50c0567f8fe1eff338257d144eaa
Author: Rossi Sun <[email protected]>
AuthorDate: Mon Mar 25 22:37:34 2024 +0800

    GH-40652: [C++] Enlarge dest buffer according to dest offset for 
`CopyBitmap` benchmark (#40769)
    
    
    
    ### Rationale for this change
    
    `CopyBitmap` benchmark doesn't make dest buffer large enough wrt. the 
possible dest offset, causing memory issues like when accessing the trailing 
bytes.
    
    ### What changes are included in this PR?
    
    Make the dest buffer wrt. dest offset.
    
    ### Are these changes tested?
    
    The fix itself is test (benchmark).
    
    ### Are there any user-facing changes?
    
    None.
    
    * GitHub Issue: #40652
    
    Authored-by: Ruoxi Sun <[email protected]>
    Signed-off-by: Antoine Pitrou <[email protected]>
---
 cpp/src/arrow/util/bit_util_benchmark.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpp/src/arrow/util/bit_util_benchmark.cc 
b/cpp/src/arrow/util/bit_util_benchmark.cc
index 3bcb4ceea6..0bf2c26f12 100644
--- a/cpp/src/arrow/util/bit_util_benchmark.cc
+++ b/cpp/src/arrow/util/bit_util_benchmark.cc
@@ -449,7 +449,7 @@ static void CopyBitmap(benchmark::State& state) {  // 
NOLINT non-const reference
   const uint8_t* src = buffer->data();
   const int64_t length = bits_size - OffsetSrc;
 
-  auto copy = *AllocateEmptyBitmap(length);
+  auto copy = *AllocateEmptyBitmap(length + OffsetDest);
 
   for (auto _ : state) {
     internal::CopyBitmap(src, OffsetSrc, length, copy->mutable_data(), 
OffsetDest);

Reply via email to