zeroshade commented on code in PR #946:
URL: https://github.com/apache/arrow-go/pull/946#discussion_r3589006276
##########
parquet/internal/utils/bit_reader.go:
##########
@@ -323,16 +323,40 @@ func (b *BitReader) GetBatchBools(out []bool) (int,
error) {
b.reader.Seek(b.byteoffset, io.SeekStart)
buf := arrow.Uint32Traits.CastToBytes(b.unpackBuf[:])
blen := buflen * 8
- for i < length {
+ for length-i >= 8 {
Review Comment:
This full-byte loop is correct, but after it (`length-i` in 1..7) the
sub-byte remainder falls through to `b.fillbuffer()` + the trailing `for ; i <
length { b.next(1) }` loop, and `fillbuffer` zero-pads / suppresses EOF — so
short input still fabricates `false` values instead of stopping.
Concrete: `out := make([]bool, 9)` over a 1-byte input decodes 8 real bits,
then the trailing loop appends a 9th `false` and returns `(9, nil)` instead of
`(8, io.ErrUnexpectedEOF)`. Same class for 1–7 bools from empty input, or 9–15
from one byte.
Also: this PR and #944 both rewrite `bit_reader.go` (#944 adds `validBits`
accounting to `next`/`fillbuffer`, which would actually close this
trailing-path gap). They will conflict — worth coordinating the two.
--
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]