diff --git a/v2/entropy/ANSRangeCodec.go b/v2/entropy/ANSRangeCodec.go index 5e93294e..7d5e65a9 100644 --- a/v2/entropy/ANSRangeCodec.go +++ b/v2/entropy/ANSRangeCodec.go @@ -874,11 +874,11 @@ func (this *ANSRangeDecoder) decodeChunkV2(block []byte) bool { st2 := int(this.bitstream.ReadBits(32)) st3 := int(this.bitstream.ReadBits(32)) - if sz == 0 { - return len(block) == 0 + if len(block) == 0 { + return true } - minBufSize := max(int(sz+(sz>>3)), len(block)) + minBufSize := max(2*len(block), 256) // protect against corrupted bitstream // Add some padding if len(this.buffer) < minBufSize {