Skip to content

Commit

Permalink
apacheGH-40652: [C++] Enlarge dest buffer according to dest offset fo…
Browse files Browse the repository at this point in the history
…r `CopyBitmap` benchmark (apache#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: apache#40652

Authored-by: Ruoxi Sun <[email protected]>
Signed-off-by: Antoine Pitrou <[email protected]>
  • Loading branch information
zanmato1984 authored Mar 25, 2024
1 parent 2b04275 commit 8133a20
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cpp/src/arrow/util/bit_util_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8133a20

Please sign in to comment.