Fix a possible endless loop when decoding aac.

Fixes ticket #789.
(cherry picked from commit e5de928923)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Carl Eugen Hoyos 2011-12-23 11:38:37 +01:00 committed by Michael Niedermayer
parent 3aa89662ce
commit a5546736bd
1 changed files with 2 additions and 2 deletions

View File

@ -819,10 +819,10 @@ static int decode_band_types(AACContext *ac, enum BandType band_type[120],
av_log(ac->avctx, AV_LOG_ERROR, "invalid band type\n");
return -1;
}
while ((sect_len_incr = get_bits(gb, bits)) == (1 << bits) - 1)
while ((sect_len_incr = get_bits(gb, bits)) == (1 << bits) - 1 && get_bits_left(gb) >= bits)
sect_end += sect_len_incr;
sect_end += sect_len_incr;
if (get_bits_left(gb) < 0) {
if (get_bits_left(gb) < 0 || sect_len_incr == (1 << bits) - 1) {
av_log(ac->avctx, AV_LOG_ERROR, overread_err);
return -1;
}