avformat/av1: fix uvlc loop past end of bitstream

When get_bits_left() returns a negative value (bitstream reader already past the end of the buffer), the while condition while (get_bits_left(gb)) evaluates to true since any non-zero int is truthy.

With the safe bitstream reader enabled, get_bits1() returns 0 past the buffer end, so the break never triggers and leading_zeros increments toward INT_MAX.

Change the condition to > 0, consistent with skip_1stop_8data_bits() which already uses <= 0 for the same pattern.

Signed-off-by: Linke <1102336121@qq.com>
This commit is contained in:
Linke
2026-03-06 19:58:45 -07:00
committed by michaelni
parent 51606de0e9
commit e44d76f61f

View File

@@ -126,8 +126,8 @@ static inline void uvlc(GetBitContext *gb)
{
int leading_zeros = 0;
while (get_bits_left(gb)) {
if (get_bits1(gb))
while (leading_zeros < 32) {
if (get_bits_left(gb) < 1 || get_bits1(gb))
break;
leading_zeros++;
}