Skip to content

Commit

Permalink
Exit early if sz == 0
Browse files Browse the repository at this point in the history
  • Loading branch information
flanglet committed Jun 21, 2024
1 parent fd6a914 commit 155dc16
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions v2/entropy/ANSRangeCodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -767,16 +767,18 @@ func (this *ANSRangeDecoder) decodeChunkV1(block []byte) {
st1 = int(this.bitstream.ReadBits(32))
}

// Read encoded data
if sz != 0 {
// Add some padding
if len(this.buffer) < int(sz) {
this.buffer = make([]byte, sz+(sz>>3))
}
if sz == 0 {
return
}

this.bitstream.ReadArray(this.buffer[0:sz], uint(8*sz))
// Add some padding
if len(this.buffer) < int(sz) {
this.buffer = make([]byte, sz+(sz>>3))
}

// Read encoded data
this.bitstream.ReadArray(this.buffer[0:sz], uint(8*sz))

n := 0
lr := this.logRange
mask := (1 << lr) - 1
Expand Down

0 comments on commit 155dc16

Please sign in to comment.