timmyb32r opened a new pull request, #11879:
URL: https://github.com/apache/arrow-rs/pull/11879

   ### Which issue does this PR close?
   
   None — standalone bug fix.
   
   ### Rationale for this change
   
   `BooleanBufferBuilder` assumes that unused bits in its trailing byte are 
zero. However, `set_bit` and `as_slice_mut` allow callers to modify those bits.
   
   As a result, appending `false` can append `true`. The same issue affects 
`append_slice`, `append_word`, `append_n` with `false`, and growing `resize`.
   
   ### What changes are included in this PR?
   
   Add a private `advance_zeroed` helper that clears trailing padding when 
exposing new bits, and use it in the affected operations.
   
   Update `append` to write its value without branching on the boolean 
argument. The public `advance` method retains its existing behavior.
   
   ### Are these changes tested?
   
   Added a regression test covering all five affected operations after 
modifying padding through either `set_bit` or `as_slice_mut`.
   
   The test checks existing values, byte boundaries, empty operations, and 
appends of up to 64 bits. It fails before the fix and passes afterward.
   
   Validation passed:
   - `cargo test -p arrow-buffer`
   - `cargo test -p arrow-buffer --all-features`
   - `cargo test --workspace`
   - `cargo clippy --workspace --all-targets --all-features -- -D warnings`
   - Formatting and spelling checks.
   
   ### Are there any significant user-facing changes?
   
   Appending values and growing the builder now produce the expected bits even 
when trailing padding was modified.
   
   ### AI assistance
   
   Codex identified the issue, generated the fix and regression test, ran 
validation, and drafted this PR description.


-- 
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]

Reply via email to