Trying not to crash on bit errors

When the pitch flag gets corrupted, make sure that pitch is actually
allowed instead of generating a bogus pitch index and crashing.
This commit is contained in:
Jean-Marc Valin 2010-05-31 21:56:12 -04:00
parent 816f893569
commit 32589cd33e

View file

@ -1672,8 +1672,16 @@ int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *da
if (has_pitch)
{
pitch_index = ec_dec_uint(dec, MAX_PERIOD-(2*N-2*N4));
int maxpitch = MAX_PERIOD-(2*N-2*N4);
if (maxpitch<0)
{
celt_notify("detected pitch when not allowed, bit corruption suspected");
pitch_index = 0;
has_pitch = 0;
} else {
pitch_index = ec_dec_uint(dec, maxpitch);
gain_id = ec_dec_uint(dec, 16);
}
} else {
pitch_index = 0;
}